Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2923,6 +2923,14 @@
"ibc/latest/middleware/callbacks/gas",
"ibc/latest/middleware/callbacks/callbacks-IBCv2"
]
},
{
"group": "Packet Forward Middleware",
"pages": [
"ibc/latest/middleware/packet-forward-middleware/overview",
"ibc/latest/middleware/packet-forward-middleware/integration",
"ibc/latest/middleware/packet-forward-middleware/example-usage"
]
}
]
},
Expand Down Expand Up @@ -3472,6 +3480,14 @@
"ibc/next/middleware/callbacks/gas",
"ibc/next/middleware/callbacks/callbacks-IBCv2"
]
},
{
"group": "Packet Forward Middleware",
"pages": [
"ibc/next/middleware/packet-forward-middleware/overview",
"ibc/next/middleware/packet-forward-middleware/integration",
"ibc/next/middleware/packet-forward-middleware/example-usage"
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ sequenceDiagram
autonumber
Chain A ->> Chain B: PFM transfer
Chain B ->> Chain C: Forward
Chain B ->> Chain C: Forward (errors)
Chain C ->> Chain B: ACK error
Chain B ->> Chain A: ACK error
```
Expand Down Expand Up @@ -111,11 +110,10 @@ sequenceDiagram

### A -> B -> C with C error ACK

10. `B` On ICS-020 ACK from `C` find `in flight packet`, delete it
11. `B` Burns or escrows tokens.
12. `B` And write error `ACK` for original packet from `A`.
13. `A` Handle ICS-020 timeout as usual
14. `C` writes success `ACK` for packet from `B`
10. `B` On ICS-020 error `ACK` from `C`, find the `in flight packet` and delete it.
11. `B` reverses the tokens it moved when forwarding, refunding them toward `A`.
12. `B` writes an error `ACK` for the original packet from `A`.
13. `A` handles the error `ACK` (a refund) as usual.

Same behavior in case of timeout on `C`

Expand All @@ -138,7 +136,7 @@ In this case `A` assets `hang` until final hop timeouts or ACK.

In the case of a timeout after 10 minutes for either forward, the packet would be retried up to 2 times, afterwards an error ack would be written to issue a refund on the prior chain.

`next` is the `memo` to pass for the next transfer hop. Per `memo` intended usage of a JSON string, it should be either JSON which will be Marshaled retaining key order, or an escaped JSON string which will be passed directly.
`next` is the `memo` to pass to the next transfer hop. Provide it either as a nested JSON object or as an escaped JSON string; PFM accepts both forms and re-serializes the value for the next hop.

`next` as JSON

Expand Down
17 changes: 4 additions & 13 deletions ibc/latest/middleware/packet-forward-middleware/integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,9 @@ Integration of the PFM should take approximately 20 minutes.

// Import the packet forward middleware
import (
packetforward "github.com/cosmos/ibc-go/v10/modules/apps/packet-forward-middleware"
packetforwardkeeper "github.com/cosmos/ibc-go/v10/modules/apps/packet-forward-middleware/keeper"
packetforwardtypes "github.com/cosmos/ibc-go/v10/modules/apps/packet-forward-middleware/types"
)

...

// Register the AppModule for the packet forward middleware module
ModuleBasics = module.NewBasicManager(
...
packetforward.AppModuleBasic{},
...
packetforward "github.com/cosmos/ibc-go/v11/modules/apps/packet-forward-middleware"
packetforwardkeeper "github.com/cosmos/ibc-go/v11/modules/apps/packet-forward-middleware/keeper"
packetforwardtypes "github.com/cosmos/ibc-go/v11/modules/apps/packet-forward-middleware/types"
)

...
Expand All @@ -48,7 +39,7 @@ type App struct {
...

// Create store keys
keys := sdk.NewKVStoreKeys(
keys := storetypes.NewKVStoreKeys(
...
packetforwardtypes.StoreKey,
...
Expand Down
12 changes: 5 additions & 7 deletions ibc/next/middleware/packet-forward-middleware/example-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ sequenceDiagram
autonumber
Chain A ->> Chain B: PFM transfer
Chain B ->> Chain C: Forward
Chain B ->> Chain C: Forward (errors)
Chain C ->> Chain B: ACK error
Chain B ->> Chain A: ACK error
```
Expand Down Expand Up @@ -113,11 +112,10 @@ sequenceDiagram

### A -> B -> C with C error ACK

10. `B` On ICS-020 ACK from `C` find `in flight packet`, delete it
11. `B` Burns or escrows tokens.
12. `B` And write error `ACK` for original packet from `A`.
13. `A` Handle ICS-020 timeout as usual
14. `C` writes success `ACK` for packet from `B`
10. `B` On ICS-020 error `ACK` from `C`, find the `in flight packet` and delete it.
11. `B` reverses the tokens it moved when forwarding, refunding them toward `A`.
12. `B` writes an error `ACK` for the original packet from `A`.
13. `A` handles the error `ACK` (a refund) as usual.

Same behavior in case of timeout on `C`

Expand All @@ -140,7 +138,7 @@ In this case `A` assets `hang` until final hop timeouts or ACK.

In the case of a timeout after 10 minutes for either forward, the packet would be retried up to 2 times, afterwards an error ack would be written to issue a refund on the prior chain.

`next` is the `memo` to pass for the next transfer hop. Per `memo` intended usage of a JSON string, it should be either JSON which will be Marshaled retaining key order, or an escaped JSON string which will be passed directly.
`next` is the `memo` to pass to the next transfer hop. Provide it either as a nested JSON object or as an escaped JSON string; PFM accepts both forms and re-serializes the value for the next hop.

`next` as JSON

Expand Down
17 changes: 4 additions & 13 deletions ibc/next/middleware/packet-forward-middleware/integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,9 @@ Integration of the PFM should take approximately 20 minutes.

// Import the packet forward middleware
import (
packetforward "github.com/cosmos/ibc-go/v10/modules/apps/packet-forward-middleware"
packetforwardkeeper "github.com/cosmos/ibc-go/v10/modules/apps/packet-forward-middleware/keeper"
packetforwardtypes "github.com/cosmos/ibc-go/v10/modules/apps/packet-forward-middleware/types"
)

...

// Register the AppModule for the packet forward middleware module
ModuleBasics = module.NewBasicManager(
...
packetforward.AppModuleBasic{},
...
packetforward "github.com/cosmos/ibc-go/v11/modules/apps/packet-forward-middleware"
packetforwardkeeper "github.com/cosmos/ibc-go/v11/modules/apps/packet-forward-middleware/keeper"
packetforwardtypes "github.com/cosmos/ibc-go/v11/modules/apps/packet-forward-middleware/types"
)

...
Expand All @@ -50,7 +41,7 @@ type App struct {
...

// Create store keys
keys := sdk.NewKVStoreKeys(
keys := storetypes.NewKVStoreKeys(
...
packetforwardtypes.StoreKey,
...
Expand Down