Skip to content

Commit

Permalink
security: revert pfm feature
Browse files Browse the repository at this point in the history
  • Loading branch information
fragwuerdig committed Mar 5, 2024
1 parent 55658bb commit 23f58aa
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 50 deletions.
23 changes: 1 addition & 22 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package keepers
import (
"path/filepath"

forward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router"
forwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/keeper"
forwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/types"
icacontrollerkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/types"
icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper"
Expand Down Expand Up @@ -104,12 +101,10 @@ type AppKeepers struct {
WasmKeeper wasmkeeper.Keeper
DyncommKeeper dyncommkeeper.Keeper
IBCHooksKeeper *ibchookskeeper.Keeper
ForwardKeeper forwardkeeper.Keeper

Ics20WasmHooks *ibchooks.WasmHooks
IBCHooksWrapper *ibchooks.ICS4Middleware
TransferStack ibctransfer.IBCModule
ForwardModule forward.AppModule

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -152,7 +147,6 @@ func NewAppKeepers(
icacontrollertypes.StoreKey,
icahosttypes.StoreKey,
ibchooktypes.StoreKey,
forwardtypes.StoreKey,
oracletypes.StoreKey,
markettypes.StoreKey,
treasurytypes.StoreKey,
Expand Down Expand Up @@ -346,17 +340,6 @@ func NewAppKeepers(
)
appKeepers.IBCHooksKeeper = &hooksKeeper

appKeepers.ForwardKeeper = *forwardkeeper.NewKeeper(
appCodec,
appKeepers.keys[forwardtypes.StoreKey],
appKeepers.GetSubspace(forwardtypes.ModuleName),
appKeepers.TransferKeeper,
appKeepers.IBCKeeper.ChannelKeeper,
appKeepers.DistrKeeper,
appKeepers.BankKeeper,
appKeepers.IBCFeeKeeper, // ICS4 Wrapper
)

// - contract keeper needs to be initialized after wasm
// - transfer needs to be initialized before wasm
// - hooks needs to be initialized before transfer
Expand All @@ -377,14 +360,13 @@ func NewAppKeepers(
appCodec,
appKeepers.keys[ibctransfertypes.StoreKey],
appKeepers.GetSubspace(ibctransfertypes.ModuleName),
&appKeepers.ForwardKeeper,
appKeepers.IBCFeeKeeper,
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
scopedTransferKeeper,
)
appKeepers.ForwardKeeper.SetTransferKeeper(appKeepers.TransferKeeper)

wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
Expand Down Expand Up @@ -474,8 +456,6 @@ func NewAppKeepers(
appKeepers.ScopedIBCFeeKeeper = scopedIBCFeeKeeper
appKeepers.ScopedWasmKeeper = scopedWasmKeeper

appKeepers.ForwardModule = forward.NewAppModule(&appKeepers.ForwardKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := appKeepers.newIBCRouter()
appKeepers.IBCKeeper.SetRouter(ibcRouter)
Expand Down Expand Up @@ -510,7 +490,6 @@ func initParamsKeeper(
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(dyncommtypes.ModuleName)
paramsKeeper.Subspace(ibchooktypes.ModuleName)
paramsKeeper.Subspace(forwardtypes.ModuleName).WithKeyTable(forwardtypes.ParamKeyTable())

return paramsKeeper
}
Expand Down
13 changes: 1 addition & 12 deletions app/keepers/routers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keepers

import (
forwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/keeper"
icacontroller "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller"
icacontrollertypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host"
Expand All @@ -13,8 +12,6 @@ import (
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"

packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router"

"github.com/classic-terra/core/v2/x/treasury"
treasurytypes "github.com/classic-terra/core/v2/x/treasury/types"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
Expand Down Expand Up @@ -50,18 +47,10 @@ func (appKeepers *AppKeepers) newIBCRouter() *porttypes.Router {
var transferStack porttypes.IBCModule
var transferHookStack porttypes.IBCModule
var transferHookFeeStack porttypes.IBCModule
var transferFwdHookFeeStack porttypes.IBCModule

transferStack = transfer.NewIBCModule(appKeepers.TransferKeeper)
transferHookStack = ibchooks.NewIBCMiddleware(transferStack, appKeepers.IBCHooksWrapper)
transferHookFeeStack = ibcfee.NewIBCMiddleware(transferHookStack, appKeepers.IBCFeeKeeper)
transferFwdHookFeeStack = packetforward.NewIBCMiddleware(
transferHookFeeStack,
&appKeepers.ForwardKeeper,
5,
forwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
forwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)

// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
Expand All @@ -86,7 +75,7 @@ func (appKeepers *AppKeepers) newIBCRouter() *porttypes.Router {

ibcRouter := porttypes.NewRouter()
ibcRouter.
AddRoute(ibctransfertypes.ModuleName, transferFwdHookFeeStack).
AddRoute(ibctransfertypes.ModuleName, transferHookFeeStack).
AddRoute(wasm.ModuleName, wasmStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack)
Expand Down
9 changes: 1 addition & 8 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
forward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router"
forwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/types"
ica "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v6/modules/apps/29-fee"
Expand All @@ -75,6 +73,7 @@ import (
ibc "github.com/cosmos/ibc-go/v6/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"

// unnamed import of statik for swagger UI support
_ "github.com/classic-terra/core/v2/client/docs/statik"
ibchooks "github.com/terra-money/core/v2/x/ibc-hooks"
Expand Down Expand Up @@ -113,7 +112,6 @@ var (
customfeegrant.AppModuleBasic{},
ibc.AppModuleBasic{},
ica.AppModuleBasic{},
forward.AppModuleBasic{},
customupgrade.AppModuleBasic{},
customevidence.AppModuleBasic{},
transfer.AppModuleBasic{},
Expand Down Expand Up @@ -186,7 +184,6 @@ func appModules(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
dyncomm.NewAppModule(appCodec, app.DyncommKeeper, app.StakingKeeper),
ibchooks.NewAppModule(app.AccountKeeper),
app.ForwardModule,
}
}

Expand Down Expand Up @@ -218,7 +215,6 @@ func simulationModules(
treasury.NewAppModule(appCodec, app.TreasuryKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
dyncomm.NewAppModule(appCodec, app.DyncommKeeper, app.StakingKeeper),
app.ForwardModule,
}
}

Expand All @@ -243,7 +239,6 @@ func orderBeginBlockers() []string {
ibchost.ModuleName,
ibctransfertypes.ModuleName,
icatypes.ModuleName,
forwardtypes.ModuleName,
ibcfeetypes.ModuleName,
ibchooktypes.ModuleName,
// Terra Classic modules
Expand Down Expand Up @@ -276,7 +271,6 @@ func orderEndBlockers() []string {
ibchost.ModuleName,
ibctransfertypes.ModuleName,
icatypes.ModuleName,
forwardtypes.ModuleName,
ibcfeetypes.ModuleName,
ibchooktypes.ModuleName,
// Terra Classic modules
Expand Down Expand Up @@ -309,7 +303,6 @@ func orderInitGenesis() []string {
ibchost.ModuleName,
ibctransfertypes.ModuleName,
icatypes.ModuleName,
forwardtypes.ModuleName,
ibcfeetypes.ModuleName,
ibchooktypes.ModuleName,
// Terra Classic modules
Expand Down
2 changes: 0 additions & 2 deletions app/upgrades/v7/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v7
import (
"github.com/classic-terra/core/v2/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"
forwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/types"
ibc_hooks_types "github.com/terra-money/core/v2/x/ibc-hooks/types"
)

Expand All @@ -15,7 +14,6 @@ var Upgrade = upgrades.Upgrade{
StoreUpgrades: store.StoreUpgrades{
Added: []string{
ibc_hooks_types.StoreKey,
forwardtypes.StoreKey,
},
},
}
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/CosmWasm/wasmvm v1.1.2
github.com/cosmos/cosmos-sdk v0.46.15
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.1
github.com/cosmos/ibc-go/v6 v6.2.1
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
Expand Down Expand Up @@ -135,7 +134,6 @@ 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.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.7 h1:ij32FaEnwxfEurtK0QKDNhTWFnz6NUmrI5gky/WnoY0=
github.com/cosmos/iavl v0.19.7/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.1 h1:2geCtV4PoNPeRnVc0HMAcRcv+7W3Mvk2nmASkGkOdzE=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.1/go.mod h1:ovYRGX7P7Vq0D54JIVlIm/47STEKgWJfw9frvL0AWGQ=
github.com/cosmos/ibc-go/v6 v6.2.1 h1:NiaDXTRhKwf3n9kELD4VRIe5zby1yk1jBvaz9tXTQ6k=
github.com/cosmos/ibc-go/v6 v6.2.1/go.mod h1:XLsARy4Y7+GtAqzMcxNdlQf6lx+ti1e8KcMGv5NIK7A=
github.com/cosmos/interchain-accounts v0.4.3 h1:WedxEa/Hj/2GY7AF6CafkEPJ/Z9rhl3rT1mRwNHsdts=
Expand Down Expand Up @@ -766,8 +764,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA=
github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
Expand Down

0 comments on commit 23f58aa

Please sign in to comment.