- Import the PFM, initialize the PFM Module & Keeper, initialize the store keys and module params, and initialize the Begin/End Block logic and InitGenesis order
- Configure the IBC application stack including the transfer module
- Configuration of additional options such as timeout period, number of retries on timeout, refund timeout period, and fee percentage
Example integration of the Packet Forward Middleware
Configuring the transfer application stack with Packet Forward Middleware
Here is an example of how to create an application stack usingtransfer
and packet-forward-middleware
.
The following transferStack
is configured in app/app.go
and added to the IBC Router
.
The in-line comments describe the execution flow of packets between the application stack and IBC core.
For more information on configuring an IBC application stack see the ibc-go docs here.
Configurable options in the Packet Forward Middleware
The Packet Forward Middleware has several configurable options available when initializing the IBC application stack. You can see these passed in as arguments topacketforward.NewIBCMiddleware
and they include the number of retries that
will be performed on a forward timeout, the timeout period that will be used for a forward, and the timeout period that
will be used for performing refunds in the case that a forward is taking too long.
Additionally, there is a fee percentage parameter that can be set in InitGenesis
, this is an optional parameter that
can be used to take a fee from each forwarded packet which will then be distributed to the community pool. In the
OnRecvPacket
callback ForwardTransferPacket
is invoked which will attempt to subtract a fee from the forwarded
packet amount if the fee percentage is non-zero.
- Retries On Timeout - how many times will a forward be re-attempted in the case of a timeout.
- Timeout Period - how long can a forward be in progress before giving up.
- Refund Timeout - how long can a forward be in progress before issuing a refund back to the original source chain.
- Fee Percentage - % of the forwarded packet amount which will be subtracted and distributed to the community pool.