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

Dang/change ibc unwinding #130

Merged
merged 10 commits into from
Apr 12, 2023
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protoImageName=ghcr.io/notional-labs/fa-proto-gen:$(protoVer)
containerProtoGen=fa-proto-gen-$(protoVer)
containerProtoFmt=fa-proto-fmt-$(protoVer)

proto-all: proto-format proto-lint proto-gen
proto-all: proto-format proto-gen

proto-gen:
@echo "Generating Protobuf files"
Expand Down
46 changes: 41 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ import (
feeabskeeper "github.com/notional-labs/fee-abstraction/v2/x/feeabs/keeper"
feeabstypes "github.com/notional-labs/fee-abstraction/v2/x/feeabs/types"

"github.com/strangelove-ventures/packet-forward-middleware/v4/router"
routerkeeper "github.com/strangelove-ventures/packet-forward-middleware/v4/router/keeper"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

appparams "github.com/notional-labs/fee-abstraction/v2/app/params"

// unnamed import of statik for swagger UI support
Expand Down Expand Up @@ -153,6 +157,7 @@ var (
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
liquidity.AppModuleBasic{},
router.AppModuleBasic{},
ica.AppModuleBasic{},
wasm.AppModuleBasic{},
feeabsmodule.AppModuleBasic{},
Expand Down Expand Up @@ -222,6 +227,8 @@ type FeeAbs struct { // nolint: golint
FeeabsKeeper feeabskeeper.Keeper
WasmKeeper wasm.Keeper

RouterKeeper *routerkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -273,7 +280,8 @@ func NewFeeAbs(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, feeabstypes.StoreKey, wasm.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, routertypes.StoreKey,
icahosttypes.StoreKey, icacontrollertypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -401,19 +409,35 @@ func NewFeeAbs(
scopedIBCKeeper,
)

// RouterKeeper must be created before TransferKeeper
app.RouterKeeper = routerkeeper.NewKeeper(
appCodec,
app.keys[routertypes.StoreKey],
app.GetSubspace(routertypes.ModuleName),
app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
app.RouterKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
)

app.RouterKeeper.SetTransferKeeper(app.TransferKeeper)
transferModule := transfer.NewAppModule(app.TransferKeeper)
routerModule := router.NewAppModule(app.RouterKeeper)

app.FeeabsKeeper = feeabskeeper.NewKeeper(
appCodec,
keys[feeabstypes.StoreKey],
Expand Down Expand Up @@ -441,8 +465,15 @@ func NewFeeAbs(
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(feeabstypes.RouterKey, feeabsmodule.NewHostZoneProposal(app.FeeabsKeeper))

transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
var ibcStack porttypes.IBCModule
ibcStack = transfer.NewIBCModule(app.TransferKeeper)
ibcStack = router.NewIBCMiddleware(
ibcStack,
app.RouterKeeper,
0,
routerkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
routerkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -510,7 +541,7 @@ func NewFeeAbs(

ibcRouter.
AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(ibctransfertypes.ModuleName, ibcStack).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(feeabstypes.ModuleName, feeabsIBCModule)

Expand Down Expand Up @@ -560,6 +591,7 @@ func NewFeeAbs(
icaModule,
// interTxModule,
feeabsModule,
routerModule,
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them
)

Expand Down Expand Up @@ -589,6 +621,7 @@ func NewFeeAbs(
ibchost.ModuleName,
feeabstypes.ModuleName,
icatypes.ModuleName,
routertypes.ModuleName,
// intertxtypes.ModuleName,
wasm.ModuleName,
)
Expand All @@ -615,6 +648,7 @@ func NewFeeAbs(
ibchost.ModuleName,
feeabstypes.ModuleName,
icatypes.ModuleName,
routertypes.ModuleName,
// intertxtypes.ModuleName,
wasm.ModuleName,
)
Expand Down Expand Up @@ -648,6 +682,7 @@ func NewFeeAbs(
ibchost.ModuleName,
feeabstypes.ModuleName,
icatypes.ModuleName,
routertypes.ModuleName,
// intertxtypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
Expand Down Expand Up @@ -950,6 +985,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(routertypes.ModuleName).WithKeyTable(routertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(feeabstypes.ModuleName)
Expand Down
34 changes: 18 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ go 1.18
require (
github.com/CosmWasm/wasmd v0.30.0
github.com/CosmWasm/wasmvm v1.1.1
github.com/cosmos/cosmos-sdk v0.45.11
github.com/cosmos/cosmos-sdk v0.45.13
github.com/cosmos/gogoproto v1.4.3
github.com/cosmos/ibc-go/v4 v4.2.0
github.com/cosmos/ibc-go/v4 v4.3.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/gravity-devs/liquidity v1.5.1
github.com/gravity-devs/liquidity v1.5.3
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/prometheus/client_golang v1.14.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.6.1
github.com/strangelove-ventures/packet-forward-middleware/v4 v4.0.5
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.24
github.com/tendermint/tendermint v0.34.26
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e
google.golang.org/grpc v1.50.1
Expand All @@ -32,8 +33,8 @@ require (
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/btcsuite/btcd v0.22.2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
Expand All @@ -42,8 +43,8 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-alpha8 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.4 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.1 // indirect
github.com/cosmos/iavl v0.19.5 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -78,6 +79,7 @@ require (
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/improbable-eng/grpc-web v0.14.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
Expand Down Expand Up @@ -114,18 +116,17 @@ require (
github.com/spf13/viper v1.14.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.5.0 // indirect
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.0 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.2.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -135,5 +136,6 @@ require (

replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.24
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
Loading