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

feat!: wire ibcfee module #3038

Merged
merged 13 commits into from
Apr 15, 2024
3 changes: 3 additions & 0 deletions .changelog/unreleased/dependencies/3038-ibc-fee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Add the [IBC Fee Module](https://ibc.cosmos.network/v7/middleware/ics29-fee/overview)
[v7.3.2](https://github.com/cosmos/ibc-go/releases/tag/v7.3.2).
mpoke marked this conversation as resolved.
Show resolved Hide resolved
([\#3038](https://github.com/cosmos/gaia/pull/3038))
3 changes: 3 additions & 0 deletions .changelog/unreleased/features/3038-ibc-fee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Add the [IBC Fee Module](https://ibc.cosmos.network/v7/middleware/ics29-fee/overview)
[v7.3.2](https://github.com/cosmos/ibc-go/releases/tag/v7.3.2).
([\#3038](https://github.com/cosmos/gaia/pull/3038))
3 changes: 3 additions & 0 deletions .changelog/unreleased/state-breaking/3038-ibc-fee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Add the [IBC Fee Module](https://ibc.cosmos.network/v7/middleware/ics29-fee/overview)
[v7.3.2](https://github.com/cosmos/ibc-go/releases/tag/v7.3.2).
([\#3038](https://github.com/cosmos/gaia/pull/3038))
20 changes: 18 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (
icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host"
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"
ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/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"
Expand Down Expand Up @@ -114,6 +117,7 @@ type AppKeepers struct {

// Modules
ICAModule ica.AppModule
IBCFeeKeeper ibcfeekeeper.Keeper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need also a scoped keeper for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TransferModule transfer.AppModule
PFMRouterModule pfmrouter.AppModule
RateLimitModule ratelimit.AppModule
Expand Down Expand Up @@ -358,12 +362,19 @@ func NewAppKeeper(
// If evidence needs to be handled for the app, set routes in router here and seal
appKeepers.EvidenceKeeper = *evidenceKeeper

appKeepers.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, appKeepers.keys[ibcfeetypes.StoreKey],
appKeepers.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
mpoke marked this conversation as resolved.
Show resolved Hide resolved
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper, appKeepers.AccountKeeper, appKeepers.BankKeeper,
)

// ICA Host keeper
appKeepers.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
appKeepers.keys[icahosttypes.StoreKey],
appKeepers.GetSubspace(icahosttypes.SubModuleName),
appKeepers.IBCKeeper.ChannelKeeper, // ICS4Wrapper
appKeepers.IBCFeeKeeper, // ICS4Wrapper
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.AccountKeeper,
Expand All @@ -389,7 +400,7 @@ func NewAppKeeper(
appCodec,
appKeepers.keys[icacontrollertypes.StoreKey],
appKeepers.GetSubspace(icacontrollertypes.SubModuleName),
appKeepers.IBCKeeper.ChannelKeeper, // ICS4Wrapper
appKeepers.IBCFeeKeeper, // ICS4Wrapper
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.ScopedICAControllerKeeper,
Expand Down Expand Up @@ -419,6 +430,7 @@ func NewAppKeeper(
appKeepers.BankKeeper,
appKeepers.ScopedTransferKeeper,
)

// Must be called on PFMRouter AFTER TransferKeeper initialized
appKeepers.PFMRouterKeeper.SetTransferKeeper(appKeepers.TransferKeeper)

Expand All @@ -432,6 +444,7 @@ func NewAppKeeper(
// - core IBC
// - ratelimit
// - pfm
// - ibcfee
// - transfer
MSalopek marked this conversation as resolved.
Show resolved Hide resolved
var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(appKeepers.TransferKeeper)
Expand All @@ -443,12 +456,15 @@ func NewAppKeeper(
pfmrouterkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)
transferStack = ratelimit.NewIBCMiddleware(appKeepers.RatelimitKeeper, transferStack)
transferStack = ibcfee.NewIBCMiddleware(transferStack, appKeepers.IBCFeeKeeper)

// Create ICAHost Stack
mpoke marked this conversation as resolved.
Show resolved Hide resolved
var icaHostStack porttypes.IBCModule = icahost.NewIBCModule(appKeepers.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, appKeepers.IBCFeeKeeper)

// Create Interchain Accounts Controller Stack
MSalopek marked this conversation as resolved.
Show resolved Hide resolved
var icaControllerStack porttypes.IBCModule = icacontroller.NewIBCMiddleware(nil, appKeepers.ICAControllerKeeper)
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, appKeepers.IBCFeeKeeper)

// Create IBC Router & seal
ibcRouter := porttypes.NewRouter().
mpoke marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"
Expand Down Expand Up @@ -46,6 +47,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
upgradetypes.StoreKey,
evidencetypes.StoreKey,
ibctransfertypes.StoreKey,
ibcfeetypes.StoreKey,
icahosttypes.StoreKey,
icacontrollertypes.StoreKey,
capabilitytypes.StoreKey,
Expand Down
8 changes: 8 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
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"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee"
ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
Expand Down Expand Up @@ -74,6 +76,7 @@ var maccPerms = map[string][]string{
govtypes.ModuleName: {authtypes.Burner},
// liquiditytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
providertypes.ConsumerRewardsPool: nil,
}

Expand Down Expand Up @@ -107,6 +110,7 @@ var ModuleBasics = module.NewBasicManager(
authzmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctm.AppModuleBasic{},
ibcfee.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
Expand Down Expand Up @@ -152,6 +156,7 @@ func appModules(
sdkparams.NewAppModule(app.ParamsKeeper),
globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
app.TransferModule,
app.ICAModule,
app.PFMRouterModule,
Expand Down Expand Up @@ -221,6 +226,7 @@ func orderBeginBlockers() []string {
icatypes.ModuleName,
pfmroutertypes.ModuleName,
ratelimittypes.ModuleName,
ibcfeetypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand Down Expand Up @@ -252,6 +258,7 @@ func orderEndBlockers() []string {
pfmroutertypes.ModuleName,
ratelimittypes.ModuleName,
capabilitytypes.ModuleName,
ibcfeetypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
Expand Down Expand Up @@ -294,6 +301,7 @@ func orderInitBlockers() []string {
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/v16/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
ratelimittypes "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/types"

icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"

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

Expand All @@ -22,6 +23,7 @@ var Upgrade = upgrades.Upgrade{
Added: []string{
ratelimittypes.ModuleName,
icacontrollertypes.SubModuleName,
ibcfeetypes.ModuleName,
},
},
}
1 change: 1 addition & 0 deletions tests/e2e/e2e_ica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (s *IntegrationTestSuite) registerICAAccount(c *chain, valIdx int, sender,
fmt.Sprintf("--from=%s", sender),
fmt.Sprintf("--%s=%s", flags.FlagFees, fees),
fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id),
"--gas=250000", // default 200_000 is not enough; gas fees increased after adding IBC fee middleware
"--keyring-backend=test",
"--broadcast-mode=sync",
"--output=json",
Expand Down
26 changes: 13 additions & 13 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ package e2e
import "fmt"

var (
runBankTest = true
runBypassMinFeeTest = true
runEncodeTest = true
runEvidenceTest = true
runFeeGrantTest = true
runGlobalFeesTest = true
runGovTest = true
runBankTest = false
MSalopek marked this conversation as resolved.
Show resolved Hide resolved
runBypassMinFeeTest = false
runEncodeTest = false
runEvidenceTest = false
runFeeGrantTest = false
runGlobalFeesTest = false
runGovTest = false
runIBCTest = true
runSlashingTest = true
runStakingAndDistributionTest = true
runVestingTest = true
runRestInterfacesTest = true
runLsmTest = true
runRateLimitTest = true
runSlashingTest = false
runStakingAndDistributionTest = false
runVestingTest = false
runRestInterfacesTest = false
runLsmTest = false
runRateLimitTest = false
)

func (s *IntegrationTestSuite) TestRestInterfaces() {
Expand Down
Loading