Skip to content

Commit

Permalink
Merge pull request #449 from ComposableFi/rustninja/cosmos-eth-fees
Browse files Browse the repository at this point in the history
Rustninja/cosmos eth fees
  • Loading branch information
RustNinja authored Mar 5, 2024
2 parents eea1da3 + 52f2358 commit 85e2bf9
Show file tree
Hide file tree
Showing 29 changed files with 3,307 additions and 17 deletions.
13 changes: 11 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import (
ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
customibctransfer "github.com/notional-labs/composable/v6/custom/ibc-transfer"
customstaking "github.com/notional-labs/composable/v6/custom/staking"
"github.com/spf13/cast"
icq "github.com/strangelove-ventures/async-icq/v7"
Expand All @@ -101,6 +102,7 @@ import (
custombankmodule "github.com/notional-labs/composable/v6/custom/bank"

"github.com/notional-labs/composable/v6/app/ante"
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware"
"github.com/notional-labs/composable/v6/x/stakingmiddleware"
transfermiddleware "github.com/notional-labs/composable/v6/x/transfermiddleware"
transfermiddlewaretypes "github.com/notional-labs/composable/v6/x/transfermiddleware/types"
Expand All @@ -126,6 +128,7 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

upgrades "github.com/notional-labs/composable/v6/app/upgrades"
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
stakingmiddlewaretypes "github.com/notional-labs/composable/v6/x/stakingmiddleware/types"
)

Expand Down Expand Up @@ -226,6 +229,7 @@ var (
consensus.AppModuleBasic{},
alliancemodule.AppModuleBasic{},
stakingmiddleware.AppModuleBasic{},
ibctransfermiddleware.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -336,7 +340,8 @@ func NewComposableApp(
devnetGov,
)

transferModule := transfer.NewAppModule(app.TransferKeeper)
// transferModule := transfer.NewAppModule(app.TransferKeeper)
transferModule := customibctransfer.NewAppModule(appCodec, app.TransferKeeper)
routerModule := router.NewAppModule(app.RouterKeeper)
transfermiddlewareModule := transfermiddleware.NewAppModule(&app.TransferMiddlewareKeeper)
txBoundaryModule := txBoundary.NewAppModule(appCodec, app.TxBoundaryKeepper)
Expand Down Expand Up @@ -371,6 +376,7 @@ func NewComposableApp(
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
customstaking.NewAppModule(appCodec, *app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
stakingmiddleware.NewAppModule(appCodec, app.StakingMiddlewareKeeper),
ibctransfermiddleware.NewAppModule(appCodec, app.IbcTransferMiddlewareKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
Expand Down Expand Up @@ -427,6 +433,7 @@ func NewComposableApp(
wasm.ModuleName,
alliancemoduletypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -462,6 +469,7 @@ func NewComposableApp(
wasm.ModuleName,
alliancemoduletypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -501,6 +509,7 @@ func NewComposableApp(
wasm.ModuleName,
alliancemoduletypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down Expand Up @@ -591,7 +600,7 @@ func (app *ComposableApp) GetStakingKeeper() ibctestingtypes.StakingKeeper {

// GetIBCKeeper implements the TestingApp interface.
func (app *ComposableApp) GetTransferKeeper() *ibctransferkeeper.Keeper {
return &app.TransferKeeper
return &app.TransferKeeper.Keeper
}

// GetIBCKeeper implements the TestingApp interface.
Expand Down
34 changes: 21 additions & 13 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ import (
icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"

ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
customibctransferkeeper "github.com/notional-labs/composable/v6/custom/ibc-transfer/keeper"
icq "github.com/strangelove-ventures/async-icq/v7"
icqkeeper "github.com/strangelove-ventures/async-icq/v7/keeper"
icqtypes "github.com/strangelove-ventures/async-icq/v7/types"
Expand Down Expand Up @@ -106,6 +107,9 @@ import (
ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types"
stakingmiddleware "github.com/notional-labs/composable/v6/x/stakingmiddleware/keeper"
stakingmiddlewaretypes "github.com/notional-labs/composable/v6/x/stakingmiddleware/types"

ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/keeper"
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

const (
Expand Down Expand Up @@ -133,7 +137,7 @@ type AppKeepers struct {
ParamsKeeper paramskeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
TransferKeeper customibctransferkeeper.Keeper
ICQKeeper icqkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
Expand All @@ -152,12 +156,13 @@ type AppKeepers struct {
ScopedRateLimitKeeper capabilitykeeper.ScopedKeeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration
TransferMiddlewareKeeper transfermiddlewarekeeper.Keeper
TxBoundaryKeepper txBoundaryKeeper.Keeper
RouterKeeper *routerkeeper.Keeper
RatelimitKeeper ratelimitmodulekeeper.Keeper
AllianceKeeper alliancemodulekeeper.Keeper
StakingMiddlewareKeeper stakingmiddleware.Keeper
TransferMiddlewareKeeper transfermiddlewarekeeper.Keeper
TxBoundaryKeepper txBoundaryKeeper.Keeper
RouterKeeper *routerkeeper.Keeper
RatelimitKeeper ratelimitmodulekeeper.Keeper
AllianceKeeper alliancemodulekeeper.Keeper
StakingMiddlewareKeeper stakingmiddleware.Keeper
IbcTransferMiddlewareKeeper ibctransfermiddleware.Keeper
}

// InitNormalKeepers initializes all 'normal' keepers.
Expand Down Expand Up @@ -191,6 +196,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
)

appKeepers.StakingMiddlewareKeeper = stakingmiddleware.NewKeeper(appCodec, appKeepers.keys[stakingmiddlewaretypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
appKeepers.IbcTransferMiddlewareKeeper = ibctransfermiddleware.NewKeeper(appCodec, appKeepers.keys[ibctransfermiddlewaretypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())

appKeepers.StakingKeeper = customstaking.NewKeeper(
appCodec, appKeepers.keys[stakingtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), &appKeepers.StakingMiddlewareKeeper,
Expand Down Expand Up @@ -294,7 +300,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.GetSubspace(transfermiddlewaretypes.ModuleName),
appCodec,
&appKeepers.RatelimitKeeper,
&appKeepers.TransferKeeper,
&appKeepers.TransferKeeper.Keeper,
appKeepers.BankKeeper,
authorityAddress,
)
Expand All @@ -305,7 +311,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
authorityAddress,
)

appKeepers.TransferKeeper = ibctransferkeeper.NewKeeper(
appKeepers.TransferKeeper = customibctransferkeeper.NewKeeper(
appCodec, appKeepers.keys[ibctransfertypes.StoreKey],
appKeepers.GetSubspace(ibctransfertypes.ModuleName),
&appKeepers.TransferMiddlewareKeeper, // ICS4Wrapper
Expand All @@ -314,13 +320,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.ScopedTransferKeeper,
&appKeepers.IbcTransferMiddlewareKeeper,
)

appKeepers.RouterKeeper = routerkeeper.NewKeeper(
appCodec,
appKeepers.keys[routertypes.StoreKey],
appKeepers.GetSubspace(routertypes.ModuleName),
appKeepers.TransferKeeper,
appKeepers.TransferKeeper.Keeper,
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.DistrKeeper,
appKeepers.BankKeeper,
Expand All @@ -340,7 +347,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

transferIBCModule := transfer.NewIBCModule(appKeepers.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(appKeepers.TransferKeeper.Keeper)
scopedICQKeeper := appKeepers.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)

appKeepers.ICQKeeper = icqkeeper.NewKeeper(
Expand Down Expand Up @@ -395,7 +402,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.ScopedWasmKeeper,
appKeepers.TransferKeeper,
appKeepers.TransferKeeper.Keeper,
bApp.MsgServiceRouter(),
bApp.GRPCQueryRouter(),
wasmDir,
Expand Down Expand Up @@ -493,6 +500,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(transfermiddlewaretypes.ModuleName)
paramsKeeper.Subspace(stakingmiddlewaretypes.ModuleName)
paramsKeeper.Subspace(ibctransfermiddlewaretypes.ModuleName)

return paramsKeeper
}
Expand Down
4 changes: 3 additions & 1 deletion app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import (

// customstakingtypes "github.com/notional-labs/composable/v6/custom/staking/types"
stakingmiddleware "github.com/notional-labs/composable/v6/x/stakingmiddleware/types"

ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

// GenerateKeys generates new keys (KV Store, Transient store, and memory store).
Expand All @@ -55,7 +57,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icqtypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, wasm08types.StoreKey,
authzkeeper.StoreKey, stakingmiddleware.StoreKey,
authzkeeper.StoreKey, stakingmiddleware.StoreKey, ibctransfermiddleware.StoreKey,
crisistypes.StoreKey, routertypes.StoreKey, transfermiddlewaretypes.StoreKey, group.StoreKey, minttypes.StoreKey, alliancemoduletypes.StoreKey, wasm.StoreKey, ibchookstypes.StoreKey, icahosttypes.StoreKey, ratelimitmoduletypes.StoreKey, txBoundaryTypes.StoreKey,
)

Expand Down
2 changes: 1 addition & 1 deletion app/test_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s TestSupport) GovKeeper() govkeeper.Keeper {
}

func (s TestSupport) TransferKeeper() ibctransferkeeper.Keeper {
return s.app.TransferKeeper
return s.app.TransferKeeper.Keeper
}

func (s TestSupport) Wasm08Keeper() wasm08.Keeper {
Expand Down
22 changes: 22 additions & 0 deletions app/upgrades/v6_4_6/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v6_4_6

import (
store "github.com/cosmos/cosmos-sdk/store/types"

"github.com/notional-labs/composable/v6/app/upgrades"
ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

const (
// UpgradeName defines the on-chain upgrade name for the composable upgrade.
UpgradeName = "v6_4_6"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{ibctransfermiddleware.StoreKey},
Deleted: []string{},
},
}
28 changes: 28 additions & 0 deletions app/upgrades/v6_4_6/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v6_4_6

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/app/upgrades"
ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
_ codec.Codec,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
// Add params for custom middleware
custommiddlewareparams := ibctransfermiddleware.DefaultGenesisState()
keepers.IbcTransferMiddlewareKeeper.SetParams(ctx, custommiddlewareparams.Params)

return mm.RunMigrations(ctx, configurator, vm)
}
}
39 changes: 39 additions & 0 deletions custom/ibc-transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package keeper

import (
"github.com/cosmos/cosmos-sdk/codec"
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/keeper"
)

type Keeper struct {
ibctransferkeeper.Keeper
cdc codec.BinaryCodec
IbcTransfermiddleware *ibctransfermiddleware.Keeper
}

func NewKeeper(
cdc codec.BinaryCodec,
key storetypes.StoreKey,
paramSpace paramtypes.Subspace,
ics4Wrapper porttypes.ICS4Wrapper,
channelKeeper types.ChannelKeeper,
portKeeper types.PortKeeper,
authKeeper types.AccountKeeper,
bk types.BankKeeper,
scopedKeeper exported.ScopedKeeper,
ibcTransfermiddleware *ibctransfermiddleware.Keeper,
) Keeper {
keeper := Keeper{
Keeper: ibctransferkeeper.NewKeeper(cdc, key, paramSpace, ics4Wrapper, channelKeeper, portKeeper, authKeeper, bk, scopedKeeper),
IbcTransfermiddleware: ibcTransfermiddleware,
cdc: cdc,
}
return keeper
}
Loading

0 comments on commit 85e2bf9

Please sign in to comment.