Skip to content

Commit

Permalink
Upgrade ibc packet forwarder. (#143)
Browse files Browse the repository at this point in the history
* Upgrade ibc packet forwarder.

* Fix some errors.

* Fix relayer images version

* Fix test invalid balance between int64 and math.Int

* Some refactors.
  • Loading branch information
tnv1 authored Jan 30, 2024
1 parent a32704a commit b06d7b4
Show file tree
Hide file tree
Showing 36 changed files with 1,151 additions and 21,183 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Go
# Go work
go.work.sum
go.work

bin/

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ build:
go build $(BUILD_FLAGS) -o bin/feeappd ./cmd/feeappd

test:
@GOWORK=off go test -race -v ./...
go test -race -v ./...

docker-build-debug:
@DOCKER_BUILDKIT=1 docker build -t feeapp:debug -f Dockerfile .
Expand Down
39 changes: 20 additions & 19 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"path/filepath"
"sort"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router"
routerkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
pfmrouter "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward"
pfmrouterkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
pfmroutertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
Expand Down Expand Up @@ -168,7 +168,7 @@ var (
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
router.AppModuleBasic{},
pfmrouter.AppModuleBasic{},
ica.AppModuleBasic{},
solomachine.AppModuleBasic{},
feeabsmodule.AppModuleBasic{},
Expand Down Expand Up @@ -237,7 +237,7 @@ type FeeAbs struct { // nolint: golint
FeeabsKeeper feeabskeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper

RouterKeeper *routerkeeper.Keeper
RouterKeeper *pfmrouterkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -289,7 +289,7 @@ func NewFeeAbs(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, feeabstypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, routertypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, pfmroutertypes.StoreKey,
icahosttypes.StoreKey, icacontrollertypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -422,16 +422,17 @@ func NewFeeAbs(
scopedIBCKeeper,
)

// RouterKeeper must be created before TransferKeeper
app.RouterKeeper = routerkeeper.NewKeeper(
// PFMRouterKeeper must be created before TransferKeeper
authority := authtypes.NewModuleAddress(govtypes.ModuleName).String()
app.RouterKeeper = pfmrouterkeeper.NewKeeper(
appCodec,
app.keys[routertypes.StoreKey],
app.GetSubspace(routertypes.ModuleName),
app.TransferKeeper,
app.keys[pfmroutertypes.StoreKey],
nil, // Will be zero-value here. Reference is set later on with SetTransferKeeper.
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
authority,
)

// Create Transfer Keepers
Expand All @@ -449,7 +450,7 @@ func NewFeeAbs(

app.RouterKeeper.SetTransferKeeper(app.TransferKeeper)
transferModule := transfer.NewAppModule(app.TransferKeeper)
routerModule := router.NewAppModule(app.RouterKeeper)
routerModule := pfmrouter.NewAppModule(app.RouterKeeper, app.GetSubspace(pfmroutertypes.ModuleName))

app.FeeabsKeeper = feeabskeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -478,12 +479,12 @@ func NewFeeAbs(

var ibcStack porttypes.IBCModule
ibcStack = transfer.NewIBCModule(app.TransferKeeper)
ibcStack = router.NewIBCMiddleware(
ibcStack = pfmrouter.NewIBCMiddleware(
ibcStack,
app.RouterKeeper,
0,
routerkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
routerkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
pfmrouterkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
pfmrouterkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
Expand Down Expand Up @@ -611,7 +612,7 @@ func NewFeeAbs(
ibcexported.ModuleName,
feeabstypes.ModuleName,
icatypes.ModuleName,
routertypes.ModuleName,
pfmroutertypes.ModuleName,
// intertxtypes.ModuleName,
)

Expand All @@ -637,7 +638,7 @@ func NewFeeAbs(
ibcexported.ModuleName,
feeabstypes.ModuleName,
icatypes.ModuleName,
routertypes.ModuleName,
pfmroutertypes.ModuleName,
// intertxtypes.ModuleName,
)

Expand Down Expand Up @@ -668,7 +669,7 @@ func NewFeeAbs(
ibcexported.ModuleName,
feeabstypes.ModuleName,
icatypes.ModuleName,
routertypes.ModuleName,
pfmroutertypes.ModuleName,
)

// Uncomment if you want to set a custom migration order here.
Expand Down Expand Up @@ -982,7 +983,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(routertypes.ModuleName).WithKeyTable(routertypes.ParamKeyTable())
paramsKeeper.Subspace(pfmroutertypes.ModuleName).WithKeyTable(pfmroutertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(feeabstypes.ModuleName)
Expand Down
Loading

0 comments on commit b06d7b4

Please sign in to comment.