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

Add Fee-Abstraction to Hub #2702

Closed
wants to merge 15 commits into from
7 changes: 6 additions & 1 deletion ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (

gaiaerrors "github.com/cosmos/gaia/v13/types/errors"
gaiafeeante "github.com/cosmos/gaia/v13/x/globalfee/ante"

feeabsante "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs/ante"
feeabskeeper "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand All @@ -23,6 +26,7 @@ type HandlerOptions struct {
Codec codec.BinaryCodec
GovKeeper *govkeeper.Keeper
IBCkeeper *ibckeeper.Keeper
FeeAbskeeper feeabskeeper.Keeper
GlobalFeeSubspace paramtypes.Subspace
StakingSubspace paramtypes.Subspace
}
Expand Down Expand Up @@ -64,7 +68,8 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
NewGovPreventSpamDecorator(opts.Codec, opts.GovKeeper),
gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingSubspace),
ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper),
feeabsante.NewFeeAbstrationMempoolFeeDecorator(opts.FeeAbskeeper),
feeabsante.NewFeeAbstractionDeductFeeDecorate(opts.AccountKeeper, opts.BankKeeper, opts.FeeAbskeeper, opts.FeegrantKeeper),
ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(opts.AccountKeeper),
ante.NewSigGasConsumeDecorator(opts.AccountKeeper, sigGasConsumer),
Expand Down
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
feeabstypes "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs/types"

gaiaante "github.com/cosmos/gaia/v13/ante"
"github.com/cosmos/gaia/v13/app/keepers"
Expand Down Expand Up @@ -202,6 +203,7 @@ func NewGaiaApp(
Codec: appCodec,
IBCkeeper: app.IBCKeeper,
GovKeeper: &app.GovKeeper,
FeeAbskeeper: app.FeeabsKeeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
StakingSubspace: app.GetSubspace(stakingtypes.ModuleName),
},
Expand Down Expand Up @@ -272,6 +274,7 @@ func (app *GaiaApp) ModuleAccountAddrs() map[string]bool {
func (app *GaiaApp) BlockedModuleAccountAddrs(modAccAddrs map[string]bool) map[string]bool {
// remove module accounts that are ALLOWED to received funds
delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())
delete(modAccAddrs, authtypes.NewModuleAddress(feeabstypes.ModuleName).String())

// Remove the ConsumerRewardsPool from the group of blocked recipient addresses in bank
delete(modAccAddrs, authtypes.NewModuleAddress(providertypes.ConsumerRewardsPool).String())
Expand Down
28 changes: 27 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/osmosis-labs/fee-abstraction/v4/x/feeabs"
feeabskeeper "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs/keeper"
feeabstypes "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs/types"

"github.com/cosmos/gaia/v13/x/globalfee"
)
Expand Down Expand Up @@ -93,6 +96,7 @@ type AppKeepers struct {
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
LiquidityKeeper liquiditykeeper.Keeper
FeeabsKeeper feeabskeeper.Keeper

// ICS
ProviderKeeper ibcproviderkeeper.Keeper
Expand All @@ -103,12 +107,14 @@ type AppKeepers struct {
ICAModule ica.AppModule
TransferModule transfer.AppModule
RouterModule router.AppModule
FeeAbsModule feeabs.AppModule
ProviderModule ibcprovider.AppModule

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedFeeabsKeeper capabilitykeeper.ScopedKeeper
ScopedIBCProviderKeeper capabilitykeeper.ScopedKeeper
}

Expand Down Expand Up @@ -154,6 +160,7 @@ func NewAppKeeper(
appKeepers.ScopedIBCKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
appKeepers.ScopedFeeabsKeeper = appKeepers.CapabilityKeeper.ScopeToModule(feeabstypes.ModuleName)
appKeepers.ScopedIBCProviderKeeper = appKeepers.CapabilityKeeper.ScopeToModule(providertypes.ModuleName)

appKeepers.CapabilityKeeper.Seal()
Expand Down Expand Up @@ -299,7 +306,8 @@ func NewAppKeeper(
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(appKeepers.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)).
AddRoute(providertypes.RouterKey, ibcprovider.NewProviderProposalHandler(appKeepers.ProviderKeeper))
AddRoute(providertypes.RouterKey, ibcprovider.NewProviderProposalHandler(appKeepers.ProviderKeeper)).
AddRoute(feeabstypes.RouterKey, feeabs.NewHostZoneProposal(appKeepers.FeeabsKeeper))

/*
Example of setting gov params:
Expand Down Expand Up @@ -344,6 +352,22 @@ func NewAppKeeper(

appKeepers.TransferModule = transfer.NewAppModule(appKeepers.TransferKeeper)

appKeepers.FeeabsKeeper = feeabskeeper.NewKeeper(
appCodec,
appKeepers.keys[feeabstypes.StoreKey],
appKeepers.GetSubspace(feeabstypes.ModuleName),
appKeepers.StakingKeeper,
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.TransferKeeper,
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.ScopedFeeabsKeeper,
)

appKeepers.FeeAbsModule = feeabs.NewAppModule(appCodec, appKeepers.FeeabsKeeper)
feeabsIBCModule := feeabs.NewIBCModule(appCodec, appKeepers.FeeabsKeeper)

appKeepers.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, appKeepers.keys[icahosttypes.StoreKey],
appKeepers.GetSubspace(icahosttypes.SubModuleName),
Expand Down Expand Up @@ -373,6 +397,7 @@ func NewAppKeeper(
ibcRouter := porttypes.NewRouter().
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, ibcStack).
AddRoute(feeabstypes.ModuleName, feeabsIBCModule).
AddRoute(providertypes.ModuleName, appKeepers.ProviderModule)

appKeepers.IBCKeeper.SetRouter(ibcRouter)
Expand Down Expand Up @@ -404,6 +429,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

paramsKeeper.Subspace(routertypes.ModuleName).WithKeyTable(routertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(feeabstypes.ModuleName)
paramsKeeper.Subspace(globalfee.ModuleName)
paramsKeeper.Subspace(providertypes.ModuleName)

Expand Down
3 changes: 2 additions & 1 deletion app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
feeabstypes "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -33,7 +34,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, liquiditytypes.StoreKey, ibctransfertypes.StoreKey,
evidencetypes.StoreKey, liquiditytypes.StoreKey, ibctransfertypes.StoreKey, feeabstypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, routertypes.StoreKey,
icahosttypes.StoreKey, providertypes.StoreKey,
)
Expand Down
12 changes: 12 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

feeabsmodule "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs"
feeabstypes "github.com/osmosis-labs/fee-abstraction/v4/x/feeabs/types"

gaiaappparams "github.com/cosmos/gaia/v13/app/params"
"github.com/cosmos/gaia/v13/x/globalfee"
)
Expand All @@ -70,6 +73,7 @@ var maccPerms = map[string][]string{
liquiditytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
providertypes.ConsumerRewardsPool: nil,
feeabstypes.ModuleName: nil,
}

// ModuleBasics defines the module BasicManager is in charge of setting up basic,
Expand All @@ -93,6 +97,9 @@ var ModuleBasics = module.NewBasicManager(
ibcproviderclient.ConsumerAdditionProposalHandler,
ibcproviderclient.ConsumerRemovalProposalHandler,
ibcproviderclient.EquivocationProposalHandler,
feeabsmodule.UpdateAddHostZoneClientProposalHandler,
feeabsmodule.UpdateDeleteHostZoneClientProposalHandler,
feeabsmodule.UpdateSetHostZoneClientProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
Expand All @@ -109,6 +116,7 @@ var ModuleBasics = module.NewBasicManager(
ica.AppModuleBasic{},
globalfee.AppModule{},
ibcprovider.AppModuleBasic{},
feeabsmodule.AppModuleBasic{},
)

func appModules(
Expand Down Expand Up @@ -146,6 +154,7 @@ func appModules(
app.TransferModule,
app.ICAModule,
app.RouterModule,
app.FeeAbsModule,
app.ProviderModule,
}
}
Expand Down Expand Up @@ -216,6 +225,7 @@ func orderBeginBlockers() []string {
paramstypes.ModuleName,
vestingtypes.ModuleName,
globalfee.ModuleName,
feeabstypes.ModuleName,
providertypes.ModuleName,
}
}
Expand Down Expand Up @@ -252,6 +262,7 @@ func orderEndBlockers() []string {
upgradetypes.ModuleName,
vestingtypes.ModuleName,
globalfee.ModuleName,
feeabstypes.ModuleName,
providertypes.ModuleName,
}
}
Expand Down Expand Up @@ -296,6 +307,7 @@ func orderInitBlockers() []string {
// min fee is empty when gentx is called.
// For more details, please refer to the following link: https://github.com/cosmos/gaia/issues/2489
globalfee.ModuleName,
feeabstypes.ModuleName,
providertypes.ModuleName,
}
}
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/gravity-devs/liquidity v1.6.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/ory/dockertest/v3 v3.10.0
github.com/osmosis-labs/fee-abstraction/v4 v4.0.0-20230918172407-be921a8c6842
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.7.0
Expand Down Expand Up @@ -48,7 +49,7 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677 // indirect
Expand All @@ -57,9 +58,10 @@ require (
github.com/cometbft/cometbft-db v0.7.0 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.1 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.5 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect
Expand Down Expand Up @@ -89,6 +91,7 @@ require (
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
Expand All @@ -115,8 +118,8 @@ require (
github.com/linxGnu/grocksdb v1.7.10 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand All @@ -132,10 +135,10 @@ require (
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
Expand All @@ -158,7 +161,7 @@ require (
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
Expand Down
Loading