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: use a generated intermediate address as the forwarder #72

Conversation

javiersuweijie
Copy link

This PR replaces #69. Instead of enforce the usage of the module account as the intermediate forwarder, PMF will generate an address based on the sender's address.

This method has the following advantages:

  1. Receiver is able to verify where the message came from by perform the intermediate address generation method
  2. When a chain does not have PFM installed, the message will fallback to the receiving account which is assumed to be controlled by the sender.

@@ -218,7 +219,7 @@ func (k *Keeper) ForwardTransferPacket(

// pay fees
if feeAmount.IsPositive() {
hostAccAddr, err := sdk.AccAddressFromBech32(receiver)
hostAccAddr, err := sdk.AccAddressFromBech32(feePayer)
Copy link
Member

Choose a reason for hiding this comment

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

the intermediateSender should be the fee payer here, as that is where the funds are received, and will be forwarded out of.

@@ -391,12 +393,21 @@ func (k *Keeper) RetryTimeout(

token := sdk.NewCoin(denom, amount)

// Handle backward compatibility for inflight packets right after the middleware upgrade
Copy link
Member

Choose a reason for hiding this comment

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

this is not necessary when the fee payer is the intermediateSender

@@ -202,7 +202,8 @@ func (k *Keeper) ForwardTransferPacket(
inFlightPacket *types.InFlightPacket,
srcPacket channeltypes.Packet,
srcPacketSender string,
receiver string,
feePayer string,
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't need to separate feePayer and intermediateSender

@@ -10,7 +10,8 @@ import (
var (
DefaultFeePercentage = sdk.NewDec(0)
// KeyFeePercentage is store's key for FeePercentage Params
KeyFeePercentage = []byte("FeePercentage")
KeyFeePercentage = []byte("FeePercentage")
IntermediateAddrPrefix = "packet-fowarder"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
IntermediateAddrPrefix = "packet-fowarder"
IntermediateAddrPrefix = "packet-forwarder"

@@ -202,7 +202,8 @@ func (k *Keeper) ForwardTransferPacket(
inFlightPacket *types.InFlightPacket,
srcPacket channeltypes.Packet,
srcPacketSender string,
receiver string,
feePayer string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this called fee payer? AFAIK the fee is paid by the relayer everywhere except for the initial send

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, I see! this is in the case where there is a forwarding fee. Interesting 🤔 I wonder if any chain has the fees enabled.

@javiersuweijie
Copy link
Author

Thanks @agouin. Somehow I thought the fee payer was going to pay in the native token existing in the account instead of using the amount that was transferred. This makes a lot more sense. Thanks for the review.

@javiersuweijie
Copy link
Author

Since the changes here are the same as #71 closing this in favour of that.

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.

3 participants