Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
67ed1ef
Added feemarket module
stana-miric Mar 21, 2024
5a68fa1
Added blocksdk support
stana-miric Mar 21, 2024
cc65aae
Removed globalfee from app
stana-miric Mar 21, 2024
0c4d33a
Cleanup and lint fix
stana-miric Mar 21, 2024
ffbe220
added post-handler and test for feemarket
dusan-maksimovic Mar 27, 2024
247596b
tests fix part 1
stana-miric Apr 2, 2024
9b9ac32
test fix part 2
stana-miric Apr 4, 2024
22fdf42
added changelog
stana-miric Apr 5, 2024
0be4697
update x/feemarket dependency
MSalopek Apr 17, 2024
943a116
fix broken dep update for feemarket
MSalopek Apr 17, 2024
dff7000
Fixed merge errors & unit tests
dusan-maksimovic May 27, 2024
080ffa1
Removed Skip Block SDK
dusan-maksimovic May 27, 2024
d745944
set upgrade params and test fixes
stana-miric May 29, 2024
c517b48
fix e2e tests & cleanup
dusan-maksimovic May 30, 2024
8cdce49
merge fix
dusan-maksimovic May 31, 2024
b9859d4
globalfee module removed from the repository
dusan-maksimovic Jun 6, 2024
0b51473
merge main branch into blocksdk-fee-market
dusan-maksimovic Jun 6, 2024
b69c7b5
simplify the check for expected user balances in e2e tests
dusan-maksimovic Jun 7, 2024
0fce83e
upgrade to a new version of the feemarket & minimum fees enforcement …
dusan-maksimovic Jun 13, 2024
2e52f4f
deps: bump feemarket v1.0.2-sdk47; bump hermes v1.9.0
MSalopek Jun 13, 2024
686744f
Merge branch 'main' into blocksdk-fee-market
MSalopek Jun 13, 2024
37541f9
scripts: update hermes configs
MSalopek Jun 13, 2024
2ae514c
update changelogs (depr x/globalfee)
MSalopek Jun 14, 2024
bd887ff
e2e: change sequence on validator genesis acc
MSalopek Jun 14, 2024
f57b72e
e2e: mv hermes calls in ibc_tests
MSalopek Jun 14, 2024
eedc862
e2e: adjust gas in staking ops
MSalopek Jun 14, 2024
9f3afd2
e2e: mv extension tests; update feegrant tests
MSalopek Jun 14, 2024
18fc6e4
deps: bump feemarket v1.0.3-sdk47
MSalopek Jun 17, 2024
9c52fe7
Merge branch 'main' into blocksdk-fee-market
MSalopek Jun 17, 2024
d387a7f
Update .changelog/unreleased/features/3028-add-feemarket
MSalopek Jun 18, 2024
4d4662c
Update .changelog/unreleased/state-breaking/3028-add-feemarket
MSalopek Jun 18, 2024
417c987
update changelogs
MSalopek Jun 18, 2024
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
1 change: 0 additions & 1 deletion .changelog/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ entry_indent = 2
# to Markdown) and a path relative to the project folder (i.e. relative to
# the parent of the `.changelog` folder).
[components.all]
globalfee = { name = "GlobalFee", path = "x/globalfee" }
tests = { name = "Tests", path = "tests" }
docs = { name = "Documentation", path = "docs" }
4 changes: 4 additions & 0 deletions .changelog/unreleased/features/3028-add-feemarket

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add one more changelog entry under api-breaking. Removing the globalfee module breaks the API, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Add feemarket module
- Remove globalfee module from the app and repository
- Remove auth module 'DeductFeeDecorator'
([\#3028](https://github.com/cosmos/gaia/pull/3028))
Comment thread
MSalopek marked this conversation as resolved.
4 changes: 4 additions & 0 deletions .changelog/unreleased/state-breaking/3028-add-feemarket
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Add feemarket module
- Remove globalfee module from the app and repository
- Remove auth module 'DeductFeeDecorator'
([\#3028](https://github.com/cosmos/gaia/pull/3028))
Comment thread
MSalopek marked this conversation as resolved.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ where:
not necessarily with the same `short-description` or content;
- `pr-number` is the PR number;
- `short-description` is a short (4 to 6 word), hyphen separated description of the change;
- `component` is used for changes that affect one of the components defined in the [config](.changelog/config.toml), e.g., `tests`, `globalfee`.
- `component` is used for changes that affect one of the components defined in the [config](.changelog/config.toml), e.g., `tests`, `docs`.

For examples, see the [.changelog](.changelog) folder.

Expand Down
29 changes: 17 additions & 12 deletions ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ante

import (
feemarketante "github.com/skip-mev/feemarket/x/feemarket/ante"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"

ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

Expand All @@ -9,22 +12,23 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

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

// UseFeeMarketDecorator to make the integration testing easier: we can switch off its ante and post decorators with this flag

@dusan-maksimovic dusan-maksimovic May 31, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a workaround to make the integration tests based on IBC testing framework work without the need to override the SendMsgs() function, since this would also require changes to the ICS repository to modify the CCVTestSuite. The only thing we would need to override is to specify the tx fees, which is not essential for these tests, so we decided not to do it. Also, our non-determinism tests were failing because the tx fees are not provided, and we are unable to provide the tx fees to the framework used, so we opted for this work-around. For the override of the SendMsgs() see the FeeMarketTestSuite.

var UseFeeMarketDecorator = true

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions
Codec codec.BinaryCodec
IBCkeeper *ibckeeper.Keeper
GlobalFeeSubspace paramtypes.Subspace
StakingKeeper *stakingkeeper.Keeper
TxFeeChecker ante.TxFeeChecker
Codec codec.BinaryCodec
IBCkeeper *ibckeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
TxFeeChecker ante.TxFeeChecker
FeeMarketKeeper *feemarketkeeper.Keeper
}

func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
Expand All @@ -40,9 +44,8 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
if opts.IBCkeeper == nil {
return nil, errorsmod.Wrap(gaiaerrors.ErrLogic, "IBC keeper is required for AnteHandler")
}

if opts.GlobalFeeSubspace.Name() == "" {
return nil, errorsmod.Wrap(gaiaerrors.ErrNotFound, "globalfee param store is required for AnteHandler")
if opts.FeeMarketKeeper == nil {
return nil, errorsmod.Wrap(gaiaerrors.ErrLogic, "FeeMarket keeper is required for AnteHandler")
}

if opts.StakingKeeper == nil {
Expand All @@ -62,8 +65,6 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
ante.NewValidateMemoDecorator(opts.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
NewGovVoteDecorator(opts.Codec, opts.StakingKeeper),
gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingKeeper),
ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper, opts.TxFeeChecker),
ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(opts.AccountKeeper),
ante.NewSigGasConsumeDecorator(opts.AccountKeeper, sigGasConsumer),
Expand All @@ -72,5 +73,9 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
ibcante.NewRedundantRelayDecorator(opts.IBCkeeper),
}

if UseFeeMarketDecorator {
anteDecorators = append(anteDecorators, feemarketante.NewFeeMarketCheckDecorator(opts.FeeMarketKeeper))
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
}
25 changes: 19 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import (
"github.com/cosmos/gaia/v18/app/params"
"github.com/cosmos/gaia/v18/app/upgrades"
v18 "github.com/cosmos/gaia/v18/app/upgrades/v18"
"github.com/cosmos/gaia/v18/x/globalfee"
)

var (
Expand Down Expand Up @@ -223,20 +222,34 @@ func NewGaiaApp(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
Codec: appCodec,
IBCkeeper: app.IBCKeeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
StakingKeeper: app.StakingKeeper,
Codec: appCodec,
IBCkeeper: app.IBCKeeper,
StakingKeeper: app.StakingKeeper,
// If TxFeeChecker is nil the default ante TxFeeChecker is used
// so we use this no-op to keep the global fee module behaviour unchanged
Comment thread
dusan-maksimovic marked this conversation as resolved.
Outdated
TxFeeChecker: noOpTxFeeChecker,
TxFeeChecker: noOpTxFeeChecker,
FeeMarketKeeper: app.FeeMarketKeeper,
},
)
if err != nil {
panic(fmt.Errorf("failed to create AnteHandler: %s", err))
}

postHandlerOptions := PostHandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeeGrantKeeper: app.FeeGrantKeeper,
FeeMarketKeeper: app.FeeMarketKeeper,
}
postHandler, err := NewPostHandler(postHandlerOptions)
if err != nil {
panic(err)
}

// set ante and post handlers
app.SetAnteHandler(anteHandler)
app.SetPostHandler(postHandler)

app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
Expand Down
13 changes: 10 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
ratelimit "github.com/Stride-Labs/ibc-rate-limiting/ratelimit"
ratelimitkeeper "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/keeper"
ratelimittypes "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/types"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand Down Expand Up @@ -77,8 +79,6 @@ 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/cosmos/gaia/v18/x/globalfee"
)

type AppKeepers struct {
Expand Down Expand Up @@ -108,6 +108,7 @@ type AppKeepers struct {
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
FeeMarketKeeper *feemarketkeeper.Keeper

// ICS
ProviderKeeper icsproviderkeeper.Keeper
Expand Down Expand Up @@ -278,6 +279,13 @@ func NewAppKeeper(
),
)

appKeepers.FeeMarketKeeper = feemarketkeeper.NewKeeper(
appCodec,
appKeepers.keys[feemarkettypes.StoreKey],
appKeepers.AccountKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// UpgradeKeeper must be created before IBCKeeper
appKeepers.UpgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
Expand Down Expand Up @@ -514,7 +522,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(pfmroutertypes.ModuleName).WithKeyTable(pfmroutertypes.ParamKeyTable())
paramsKeeper.Subspace(ratelimittypes.ModuleName)
paramsKeeper.Subspace(globalfee.ModuleName)
paramsKeeper.Subspace(providertypes.ModuleName)

return paramsKeeper
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keepers

import (
ratelimittypes "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/types"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

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"
Expand Down Expand Up @@ -57,6 +58,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
ratelimittypes.StoreKey,
providertypes.StoreKey,
consensusparamtypes.StoreKey,
feemarkettypes.StoreKey,
)

// Define transient store keys
Expand Down
26 changes: 14 additions & 12 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package gaia
import (
ratelimit "github.com/Stride-Labs/ibc-rate-limiting/ratelimit"
ratelimittypes "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/types"
feemarket "github.com/skip-mev/feemarket/x/feemarket"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

pfmrouter "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward"
pfmroutertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
Expand Down Expand Up @@ -61,7 +63,6 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

gaiaappparams "github.com/cosmos/gaia/v18/app/params"
"github.com/cosmos/gaia/v18/x/globalfee"
"github.com/cosmos/gaia/v18/x/metaprotocols"
metaprotocolstypes "github.com/cosmos/gaia/v18/x/metaprotocols/types"
)
Expand All @@ -78,6 +79,8 @@ var maccPerms = map[string][]string{
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
providertypes.ConsumerRewardsPool: nil,
feemarkettypes.ModuleName: nil,
feemarkettypes.FeeCollectorName: nil,
}

// ModuleBasics defines the module BasicManager is in charge of setting up basic,
Expand Down Expand Up @@ -118,10 +121,10 @@ var ModuleBasics = module.NewBasicManager(
pfmrouter.AppModuleBasic{},
ratelimit.AppModuleBasic{},
ica.AppModuleBasic{},
globalfee.AppModule{},
icsprovider.AppModuleBasic{},
consensus.AppModuleBasic{},
metaprotocols.AppModuleBasic{},
feemarket.AppModuleBasic{},
)

func appModules(
Expand Down Expand Up @@ -154,7 +157,6 @@ func appModules(
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
sdkparams.NewAppModule(app.ParamsKeeper),
globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
app.TransferModule,
Expand All @@ -164,6 +166,7 @@ func appModules(

app.ProviderModule,
metaprotocols.NewAppModule(),
feemarket.NewAppModule(appCodec, *app.FeeMarketKeeper),
}
}

Expand Down Expand Up @@ -232,7 +235,7 @@ func orderBeginBlockers() []string {
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
globalfee.ModuleName,
feemarkettypes.ModuleName,
providertypes.ModuleName,
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
Expand Down Expand Up @@ -271,7 +274,7 @@ func orderEndBlockers() []string {
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
globalfee.ModuleName,
feemarkettypes.ModuleName,
providertypes.ModuleName,
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
Expand Down Expand Up @@ -310,15 +313,14 @@ func orderInitBlockers() []string {
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
// The globalfee module should ideally be initialized before the genutil module in theory:
// The globalfee antehandler performs checks in DeliverTx, which is called by gentx.
// When the global fee > 0, gentx needs to pay the fee. However, this is not expected,
// (in our case, the global fee is initialized with an empty value, which might not be a problem
// if the globalfee in genesis is not changed.)
// To resolve this issue, we should initialize the globalfee module after genutil, ensuring that the global
// The feemarket module should ideally be initialized before the genutil module in theory:
// The feemarket antehandler performs checks in DeliverTx, which is called by gentx.
// When the fee > 0, gentx needs to pay the fee. However, this is not expected.
// To resolve this issue, we should initialize the feemarket module after genutil, ensuring that the
// min fee is empty when gentx is called.
// A similar issue existed for the 'globalfee' module, which was previously used instead of 'feemarket'.
// For more details, please refer to the following link: https://github.com/cosmos/gaia/issues/2489
globalfee.ModuleName,
feemarkettypes.ModuleName,
providertypes.ModuleName,
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
Expand Down
50 changes: 50 additions & 0 deletions app/post.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package gaia

import (
feemarketpost "github.com/skip-mev/feemarket/x/feemarket/post"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/cosmos/gaia/v18/ante"
)

// PostHandlerOptions are the options required for constructing a FeeMarket PostHandler.
type PostHandlerOptions struct {
AccountKeeper feemarketpost.AccountKeeper
BankKeeper feemarketpost.BankKeeper
FeeMarketKeeper feemarketpost.FeeMarketKeeper
FeeGrantKeeper feemarketpost.FeeGrantKeeper
}

// NewPostHandler returns a PostHandler chain with the fee deduct decorator.
func NewPostHandler(options PostHandlerOptions) (sdk.PostHandler, error) {
if !ante.UseFeeMarketDecorator {
return nil, nil
}

if options.AccountKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for post builder")
}

if options.BankKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for post builder")
}

if options.FeeMarketKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "feemarket keeper is required for post builder")
}

postDecorators := []sdk.PostDecorator{
feemarketpost.NewFeeMarketDeductDecorator(
options.AccountKeeper,
options.BankKeeper,
options.FeeGrantKeeper,
options.FeeMarketKeeper,
),
}

return sdk.ChainPostDecorators(postDecorators...), nil
}
3 changes: 3 additions & 0 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func TestAppStateDeterminism(t *testing.T) {
t.Skip("skipping application simulation")
}

// since we can't provide tx fees to SimulateFromSeed(), we must switch off the feemarket
ante.UseFeeMarketDecorator = false

config := sim.NewConfigFromFlags()
config.InitialBlockHeight = 1
config.ExportParamsPath = ""
Expand Down
15 changes: 14 additions & 1 deletion app/upgrades/v18/constants.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
package v18

import (
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

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

"github.com/cosmos/gaia/v18/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v18"
UpgradeName = "v18"
GlobalFeeModuleName = "globalfee"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
feemarkettypes.ModuleName,
},
Deleted: []string{
GlobalFeeModuleName,
},
},
}
Loading