-
Notifications
You must be signed in to change notification settings - Fork 751
feat: Packet forward middleware #8285
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
Merged
Merged
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
58e0268
chore: update minor dependencies
DeshErBojhaa 863799f
feat: move packet_forward_middleware from ibc-app to ibc-go repo.
DeshErBojhaa 2f0b0b0
fix: run go mod tidy
DeshErBojhaa 048215d
Merge branch 'main' into tamjid/pfm-homecoming
DeshErBojhaa 7b7a159
feat: Unit tests for Packet Forward Middleware (#8313)
DeshErBojhaa ae228c4
e2e: Port tests for packet forward middleware module (#8292)
DeshErBojhaa 695ee1d
chore: bump sdk math to 1.5.3 (#8293)
gjermundgaraba fadf346
test(07-tendermint): remove unused expPass in TestSetAndGetParams (#8…
hungdinh82 e665141
test(08-wasm): replace expPass with expError in TestNewKeeper (#8280)
hungdinh82 554de1c
chore: bump go-ethereum to v1.15.8 (#8295)
gjermundgaraba 76e2ef2
docs: add versioned docs for v10 (#8279)
gjermundgaraba ca1cbdb
rename total_escrow query path (#8287)
vladjdk 4f48209
docs: set v10 as default (#8301)
gjermundgaraba 209f0cd
feat: allow scaling of trusting period for client upgrades (#8185)
damiannolan 187fdf3
chore: prep v10.2.x mergify (#8305)
gjermundgaraba e48f6df
chore: fix test TestSetGetTotalEscrowForDenom, use expected errors (#…
hungdinh82 580420c
chore: bump deps (#8304)
gjermundgaraba 11f5a79
chore: remove datahash from ica account creation (#8307)
gjermundgaraba 093b44f
feat: sdk v53 upgrade (#8254)
7234ec5
chore: bump cosmossdk.io/api from v0.9.0 to v0.9.2 (#8326)
gjermundgaraba 6652880
chore(deps): bump github.com/ethereum/go-ethereum from 1.15.8 to 1.15…
dependabot[bot] 6e9ba42
chore: update to official sdk v0.53 release (#8329)
17724ed
chore: add changelog for v10.2.0 (#8331)
gjermundgaraba 4ead143
chore: fixed proto-lint errors (#8336)
srdtrk d9f49a2
chore: bumped go version used by wasm dockerfile (#8354)
srdtrk f883b96
chore: remove modules/core/specs (#8350)
gjermundgaraba 64ca973
feat: Prefix-based routing in IBCv2 Router (#8303)
kulikthebird 6c785a8
chore: remove e2e fork and draft restrictions (#8359)
gjermundgaraba 3cfc3f6
bump wasmvm to v2.2.4, go-etheruem to v1.15.11, spf13/cast to v1.8.0 …
gjermundgaraba 618a409
e2e: Create only required number of chains. (#8371)
DeshErBojhaa 4bf9be1
chore: update minor dependencies
DeshErBojhaa 7dda020
feat: move packet_forward_middleware from ibc-app to ibc-go repo.
DeshErBojhaa 7317ae2
fix: run go mod tidy
DeshErBojhaa 0b6af28
feat: Unit tests for Packet Forward Middleware (#8313)
DeshErBojhaa 9b399c7
e2e: Port tests for packet forward middleware module (#8292)
DeshErBojhaa f5de71c
sync dep
DeshErBojhaa 36fa262
fix: lint - Shutup Meg!
DeshErBojhaa 6bbbd0b
feat: sdk v53 upgrade (#8254)
67abf32
chore: update to official sdk v0.53 release (#8329)
575f650
e2e: Create only required number of chains. (#8371)
DeshErBojhaa 1f5a087
feat: move packet_forward_middleware from ibc-app to ibc-go repo.
DeshErBojhaa 2749602
feat: Unit tests for Packet Forward Middleware (#8313)
DeshErBojhaa 983a045
e2e: Port tests for packet forward middleware module (#8292)
DeshErBojhaa 05fd50e
feat: sdk v53 upgrade (#8254)
eb227b6
chore: update to official sdk v0.53 release (#8329)
18b514b
e2e: Create only required number of chains. (#8371)
DeshErBojhaa c8b8ac2
Merge branch 'main' of github.com:cosmos/ibc-go into tamjid/pfm-homec…
DeshErBojhaa 735636d
sync dep: WTF!!
DeshErBojhaa 8819f59
fix lint: Shutup Meg!
DeshErBojhaa 0aa1e9f
fix e2e
DeshErBojhaa 2fcf66c
changelog
DeshErBojhaa bc5df6a
fix markdown lint
DeshErBojhaa b2433d0
Merge remote-tracking branch 'origin/main' into tamjid/pfm-homecoming
gjermundgaraba deab81c
Merge branch 'main' into tamjid/pfm-homecoming
gjermundgaraba 0fe788e
address pr comment
DeshErBojhaa 0adb957
add comment
DeshErBojhaa d4f5dbf
fix: removed unused key
DeshErBojhaa a1ac2e0
refactor: removed unused func from expected keepers
DeshErBojhaa 38ca1d9
fix: Removed duplicated makefile
DeshErBojhaa 665fed0
Removed unused tar files
DeshErBojhaa 9dec322
refactor: remove unused param subspace
DeshErBojhaa b6ec134
refactor: simplify logic for getting inflight packets from KV store
DeshErBojhaa 1143ceb
refactor: remove unclear function
DeshErBojhaa 0018d29
refactor: remove dup interface
DeshErBojhaa b225209
chore: bump deps + lint (#8383)
gjermundgaraba affe099
fix dep
DeshErBojhaa 596d4ee
fix dep
DeshErBojhaa 4d63041
sync dep
DeshErBojhaa e8306cd
Merge branch 'main' of github.com:cosmos/ibc-go into tamjid/pfm-homec…
DeshErBojhaa 94ed241
refactor: rename function param
DeshErBojhaa f6ab855
Merge branch 'main' of github.com:cosmos/ibc-go into tamjid/pfm-homec…
DeshErBojhaa d31125d
move CallbacksCompatibleModuleV2 to api
gjermundgaraba f24e6a9
rename CallbacksCompatibleModuleV2 to PacketUnmarshalarModuleV2
gjermundgaraba 1947674
Merge branch 'main' into tamjid/pfm-homecoming
gjermundgaraba 16134a6
add note on module name spelling mistake
gjermundgaraba f2a204a
remove commented out import in genesis.proto
gjermundgaraba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
docs/docs/02-apps/03-packet-forward-middleware/integration.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| # Integration | ||
|
|
||
| This document provides instructions on integrating and configuring the Packet Forward Middleware (PFM) within your | ||
| existing chain implementation. This document is *NOT* a guide on developing with the Cosmos SDK or ibc-go and makes | ||
| the assumption that you have some existing codebase for your chain with IBC already enabled. | ||
|
|
||
| The integration steps include the following: | ||
|
|
||
| 1. 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. | ||
| 2. Configure the IBC application stack including the transfer module. | ||
| 3. Configuration of additional options such as timeout period, number of retries on timeout, refund timeout period, and fee percentage. | ||
|
|
||
| Integration of the PFM should take approximately 20 minutes. | ||
|
|
||
| ## Example integration of the Packet Forward Middleware | ||
|
|
||
| ```go | ||
| // app.go | ||
|
|
||
| // Import the packet forward middleware | ||
| import ( | ||
| "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v10/packetforward" | ||
| packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v10/packetforward/keeper" | ||
| packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v10/packetforward/types" | ||
| ) | ||
|
|
||
| ... | ||
|
|
||
| // Register the AppModule for the packet forward middleware module | ||
| ModuleBasics = module.NewBasicManager( | ||
| ... | ||
| packetforward.AppModuleBasic{}, | ||
| ... | ||
| ) | ||
|
|
||
| ... | ||
|
|
||
| // Add packet forward middleware Keeper | ||
| type App struct { | ||
| ... | ||
| PacketForwardKeeper *packetforwardkeeper.Keeper | ||
| ... | ||
| } | ||
|
|
||
| ... | ||
|
|
||
| // Create store keys | ||
| keys := sdk.NewKVStoreKeys( | ||
| ... | ||
| packetforwardtypes.StoreKey, | ||
| ... | ||
| ) | ||
|
|
||
| ... | ||
|
|
||
| // Initialize the packet forward middleware Keeper | ||
| // It's important to note that the PFM Keeper must be initialized before the Transfer Keeper | ||
| app.PacketForwardKeeper = packetforwardkeeper.NewKeeper( | ||
| appCodec, | ||
| keys[packetforwardtypes.StoreKey], | ||
| nil, // will be zero-value here, reference is set later on with SetTransferKeeper. | ||
| app.IBCKeeper.ChannelKeeper, | ||
| appKeepers.DistrKeeper, | ||
| app.BankKeeper, | ||
| app.IBCKeeper.ChannelKeeper, | ||
| authtypes.NewModuleAddress(govtypes.ModuleName).String(), | ||
| ) | ||
|
|
||
| // Initialize the transfer module Keeper | ||
| app.TransferKeeper = ibctransferkeeper.NewKeeper( | ||
| appCodec, | ||
| keys[ibctransfertypes.StoreKey], | ||
| app.GetSubspace(ibctransfertypes.ModuleName), | ||
| app.PacketForwardKeeper, | ||
| app.IBCKeeper.ChannelKeeper, | ||
| &app.IBCKeeper.PortKeeper, | ||
| app.AccountKeeper, | ||
| app.BankKeeper, | ||
| scopedTransferKeeper, | ||
| ) | ||
|
|
||
| app.PacketForwardKeeper.SetTransferKeeper(app.TransferKeeper) | ||
|
|
||
| // See the section below for configuring an application stack with the packet forward middleware | ||
|
|
||
| ... | ||
|
|
||
| // Register packet forward middleware AppModule | ||
| app.moduleManager = module.NewManager( | ||
| ... | ||
| packetforward.NewAppModule(app.PacketForwardKeeper, app.GetSubspace(packetforwardtypes.ModuleName)), | ||
| ) | ||
|
|
||
| ... | ||
|
|
||
| // Add packet forward middleware to begin blocker logic | ||
| app.moduleManager.SetOrderBeginBlockers( | ||
| ... | ||
| packetforwardtypes.ModuleName, | ||
| ... | ||
| ) | ||
|
|
||
| // Add packet forward middleware to end blocker logic | ||
| app.moduleManager.SetOrderEndBlockers( | ||
| ... | ||
| packetforwardtypes.ModuleName, | ||
| ... | ||
| ) | ||
|
|
||
| // Add packet forward middleware to init genesis logic | ||
| app.moduleManager.SetOrderInitGenesis( | ||
| ... | ||
| packetforwardtypes.ModuleName, | ||
| ... | ||
| ) | ||
|
|
||
| // Add packet forward middleware to init params keeper | ||
| func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { | ||
| ... | ||
| paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable()) | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ## Configuring the transfer application stack with Packet Forward Middleware | ||
|
|
||
| Here is an example of how to create an application stack using `transfer` 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](https://github.com/cosmos/ibc-go/blob/e69a833de764fa0f5bdf0338d9452fd6e579a675/docs/docs/04-middleware/01-ics29-fee/02-integration.md#configuring-an-application-stack-with-fee-middleware). | ||
|
|
||
| ```go | ||
| // Create Transfer Stack | ||
| // SendPacket, since it is originating from the application to core IBC: | ||
| // transferKeeper.SendPacket -> packetforward.SendPacket -> channel.SendPacket | ||
|
|
||
| // RecvPacket, message that originates from core IBC and goes down to app, the flow is the other way | ||
| // channel.RecvPacket -> packetforward.OnRecvPacket -> transfer.OnRecvPacket | ||
|
|
||
| // transfer stack contains (from top to bottom): | ||
| // - Packet Forward Middleware | ||
| // - Transfer | ||
| var transferStack ibcporttypes.IBCModule | ||
| transferStack = transfer.NewIBCModule(app.TransferKeeper) | ||
| transferStack = packetforward.NewIBCMiddleware( | ||
| transferStack, | ||
| app.PacketForwardKeeper, | ||
| 0, // retries on timeout | ||
| packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, // forward timeout | ||
| ) | ||
|
|
||
| // Add transfer stack to IBC Router | ||
| ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack) | ||
| ``` | ||
|
|
||
| ## 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 to `packetforward.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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.