From b3fc50ecd62e8d7b827a33b2063aa79e700747b4 Mon Sep 17 00:00:00 2001 From: colmazia Date: Thu, 20 Feb 2025 14:56:22 +0700 Subject: [PATCH] add feemarket module with base fee 0.0025uband, delete globalfee module --- app/ante.go | 74 ++- app/app.go | 86 ++- app/genesis.go | 18 +- app/keepers/keepers.go | 32 +- app/keepers/keys.go | 5 +- app/modules.go | 46 +- app/post.go | 36 +- app/upgrades/v3/constants.go | 94 --- app/upgrades/v3_mainnet/constants.go | 102 +++ app/upgrades/{v3 => v3_mainnet}/upgrades.go | 26 +- .../{v3 => v3_mainnet}/upgrades_test.go | 27 +- app/upgrades/v3_testnet/constants.go | 42 ++ app/upgrades/v3_testnet/upgrades.go | 109 ++++ app/upgrades/v3_testnet/upgrades_test.go | 99 +++ go.mod | 11 +- go.sum | 22 +- testing/tx_helpers.go | 3 + x/bank/app_test.go | 15 +- x/globalfee/README.md | 4 - x/globalfee/client/cli/query.go | 48 -- x/globalfee/feechecker/feechecker.go | 142 ---- x/globalfee/feechecker/feechecker_test.go | 161 ----- x/globalfee/feechecker/utils.go | 68 -- x/globalfee/feechecker/utils_test.go | 127 ---- x/globalfee/genesis_test.go | 64 -- x/globalfee/keeper/genesis.go | 20 - x/globalfee/keeper/genesis_test.go | 84 --- x/globalfee/keeper/grpc_query.go | 24 - x/globalfee/keeper/grpc_query_test.go | 79 --- x/globalfee/keeper/keeper.go | 60 -- x/globalfee/keeper/keeper_test.go | 151 ----- x/globalfee/keeper/msg_server.go | 43 -- x/globalfee/keeper/msg_server_test.go | 128 ---- x/globalfee/module.go | 121 ---- x/globalfee/types/codec.go | 25 - x/globalfee/types/genesis.go | 43 -- x/globalfee/types/genesis.pb.go | 522 --------------- x/globalfee/types/keys.go | 17 - x/globalfee/types/msgs.go | 26 - x/globalfee/types/params.go | 32 - x/globalfee/types/params_test.go | 64 -- x/globalfee/types/query.pb.go | 538 ---------------- x/globalfee/types/query.pb.gw.go | 153 ----- x/globalfee/types/tx.pb.go | 605 ------------------ x/oracle/app_test.go | 1 + x/oracle/ibc_test.go | 1 + 46 files changed, 637 insertions(+), 3561 deletions(-) delete mode 100644 app/upgrades/v3/constants.go create mode 100644 app/upgrades/v3_mainnet/constants.go rename app/upgrades/{v3 => v3_mainnet}/upgrades.go (87%) rename app/upgrades/{v3 => v3_mainnet}/upgrades_test.go (73%) create mode 100644 app/upgrades/v3_testnet/constants.go create mode 100644 app/upgrades/v3_testnet/upgrades.go create mode 100644 app/upgrades/v3_testnet/upgrades_test.go delete mode 100644 x/globalfee/README.md delete mode 100644 x/globalfee/client/cli/query.go delete mode 100644 x/globalfee/feechecker/feechecker.go delete mode 100644 x/globalfee/feechecker/feechecker_test.go delete mode 100644 x/globalfee/feechecker/utils.go delete mode 100644 x/globalfee/feechecker/utils_test.go delete mode 100644 x/globalfee/genesis_test.go delete mode 100644 x/globalfee/keeper/genesis.go delete mode 100644 x/globalfee/keeper/genesis_test.go delete mode 100644 x/globalfee/keeper/grpc_query.go delete mode 100644 x/globalfee/keeper/grpc_query_test.go delete mode 100644 x/globalfee/keeper/keeper.go delete mode 100644 x/globalfee/keeper/keeper_test.go delete mode 100644 x/globalfee/keeper/msg_server.go delete mode 100644 x/globalfee/keeper/msg_server_test.go delete mode 100644 x/globalfee/module.go delete mode 100644 x/globalfee/types/codec.go delete mode 100644 x/globalfee/types/genesis.go delete mode 100644 x/globalfee/types/genesis.pb.go delete mode 100644 x/globalfee/types/keys.go delete mode 100644 x/globalfee/types/msgs.go delete mode 100644 x/globalfee/types/params.go delete mode 100644 x/globalfee/types/params_test.go delete mode 100644 x/globalfee/types/query.pb.go delete mode 100644 x/globalfee/types/query.pb.gw.go delete mode 100644 x/globalfee/types/tx.pb.go diff --git a/app/ante.go b/app/ante.go index b7dd46208..a170723d3 100644 --- a/app/ante.go +++ b/app/ante.go @@ -1,39 +1,56 @@ package band 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/v8/modules/core/ante" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + storetypes "cosmossdk.io/store/types" + txsigning "cosmossdk.io/x/tx/signing" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/bandprotocol/chain/v3/app/mempool" bandtsskeeper "github.com/bandprotocol/chain/v3/x/bandtss/keeper" feedskeeper "github.com/bandprotocol/chain/v3/x/feeds/keeper" - "github.com/bandprotocol/chain/v3/x/globalfee/feechecker" - globalfeekeeper "github.com/bandprotocol/chain/v3/x/globalfee/keeper" oraclekeeper "github.com/bandprotocol/chain/v3/x/oracle/keeper" tsskeeper "github.com/bandprotocol/chain/v3/x/tss/keeper" ) +// UseFeeMarketDecorator to make the integration testing easier: we can switch off its ante and post decorators with this flag +var UseFeeMarketDecorator = true + // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC // channel keeper. type HandlerOptions struct { - ante.HandlerOptions - Cdc codec.Codec + Cdc codec.Codec + ExtensionOptionChecker ante.ExtensionOptionChecker + SignModeHandler *txsigning.HandlerMap + SigGasConsumer func(meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params) error + TxFeeChecker ante.TxFeeChecker + + AccountKeeper feemarketante.AccountKeeper + BankKeeper feemarketante.BankKeeper + FeegrantKeeper ante.FeegrantKeeper AuthzKeeper *authzkeeper.Keeper OracleKeeper *oraclekeeper.Keeper IBCKeeper *ibckeeper.Keeper StakingKeeper *stakingkeeper.Keeper - GlobalfeeKeeper *globalfeekeeper.Keeper + FeeMarketKeeper *feemarketkeeper.Keeper TSSKeeper *tsskeeper.Keeper BandtssKeeper *bandtsskeeper.Keeper FeedsKeeper *feedskeeper.Keeper - Lanes []*mempool.Lane + + Lanes []*mempool.Lane } func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { @@ -70,8 +87,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { if options.StakingKeeper == nil { return nil, sdkerrors.ErrLogic.Wrap("Staking keeper is required for AnteHandler") } - if options.GlobalfeeKeeper == nil { - return nil, sdkerrors.ErrLogic.Wrap("Globalfee keeper is required for AnteHandler") + if options.FeeMarketKeeper == nil { + return nil, sdkerrors.ErrLogic.Wrap("FeeMarket keeper is required for AnteHandler") } sigGasConsumer := options.SigGasConsumer @@ -79,20 +96,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { sigGasConsumer = ante.DefaultSigVerificationGasConsumer } - if options.TxFeeChecker == nil { - feeChecker := feechecker.NewFeeChecker( - options.Cdc, - options.AuthzKeeper, - options.OracleKeeper, - options.GlobalfeeKeeper, - options.StakingKeeper, - options.TSSKeeper, - options.BandtssKeeper, - options.FeedsKeeper, - ) - options.TxFeeChecker = feeChecker.CheckTxFee - } - anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first(), ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), @@ -100,15 +103,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - NewIgnoreDecorator( - ante.NewDeductFeeDecorator( - options.AccountKeeper, - options.BankKeeper, - options.FeegrantKeeper, - options.TxFeeChecker, - ), - options.Lanes..., - ), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewSetPubKeyDecorator(options.AccountKeeper), ante.NewValidateSigCountDecorator(options.AccountKeeper), @@ -118,6 +112,24 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ibcante.NewRedundantRelayDecorator(options.IBCKeeper), } + if UseFeeMarketDecorator { + anteDecorators = append(anteDecorators, + NewIgnoreDecorator( + feemarketante.NewFeeMarketCheckDecorator( + options.AccountKeeper, + options.BankKeeper, + options.FeegrantKeeper, + options.FeeMarketKeeper, + ante.NewDeductFeeDecorator( + options.AccountKeeper, + options.BankKeeper, + options.FeegrantKeeper, + options.TxFeeChecker)), + options.Lanes..., + ), + ) + } + return sdk.ChainAnteDecorators(anteDecorators...), nil } diff --git a/app/app.go b/app/app.go index 835cd1ba7..e6779a0d9 100644 --- a/app/app.go +++ b/app/app.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper" "github.com/spf13/cast" abci "github.com/cometbft/cometbft/abci/types" @@ -21,6 +22,7 @@ import ( "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/appmodule" "cosmossdk.io/log" + "cosmossdk.io/math" "cosmossdk.io/x/tx/signing" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -40,6 +42,7 @@ import ( "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/msgservice" sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -55,7 +58,7 @@ import ( "github.com/bandprotocol/chain/v3/app/keepers" "github.com/bandprotocol/chain/v3/app/mempool" "github.com/bandprotocol/chain/v3/app/upgrades" - v3 "github.com/bandprotocol/chain/v3/app/upgrades/v3" + v3 "github.com/bandprotocol/chain/v3/app/upgrades/v3_mainnet" nodeservice "github.com/bandprotocol/chain/v3/client/grpc/node" proofservice "github.com/bandprotocol/chain/v3/client/grpc/oracle/proof" oraclekeeper "github.com/bandprotocol/chain/v3/x/oracle/keeper" @@ -269,29 +272,42 @@ func NewBandApp( anteHandler, err := NewAnteHandler( HandlerOptions{ - HandlerOptions: ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - SignModeHandler: txConfig.SignModeHandler(), - FeegrantKeeper: app.FeeGrantKeeper, - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - }, Cdc: app.appCodec, + SignModeHandler: txConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + TxFeeChecker: func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { + return minTxFeesChecker(ctx, tx, *app.FeeMarketKeeper) + }, + + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + FeegrantKeeper: app.FeeGrantKeeper, AuthzKeeper: &app.AuthzKeeper, OracleKeeper: &app.OracleKeeper, + IBCKeeper: app.IBCKeeper, + StakingKeeper: app.StakingKeeper, + FeeMarketKeeper: app.FeeMarketKeeper, TSSKeeper: app.TSSKeeper, BandtssKeeper: &app.BandtssKeeper, FeedsKeeper: &app.FeedsKeeper, - IBCKeeper: app.IBCKeeper, - StakingKeeper: app.StakingKeeper, - GlobalfeeKeeper: &app.GlobalFeeKeeper, - Lanes: []*mempool.Lane{feedsLane, tssLane, oracleLane}, // every lane except default lane + + Lanes: []*mempool.Lane{feedsLane, tssLane, oracleLane}, // every lane except default lane }, ) if err != nil { panic(fmt.Errorf("failed to create ante handler: %s", err)) } + postHandlerOptions := PostHandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + FeeMarketKeeper: app.FeeMarketKeeper, + } + postHandler, err := NewPostHandler(postHandlerOptions) + if err != nil { + panic(err) + } + // proposal handler proposalHandler := mempool.NewDefaultProposalHandler(app.Logger(), txConfig.TxDecoder(), bandMempool) @@ -299,13 +315,6 @@ func NewBandApp( app.SetPrepareProposal(proposalHandler.PrepareProposalHandler()) app.SetProcessProposal(proposalHandler.ProcessProposalHandler()) - postHandler, err := NewPostHandler( - PostHandlerOptions{}, - ) - if err != nil { - panic(fmt.Errorf("failed to create post handler: %s", err)) - } - // set ante and post handlers app.SetAnteHandler(anteHandler) app.SetPostHandler(postHandler) @@ -527,3 +536,42 @@ func (app *BandApp) AutoCliOpts() autocli.AppOptions { ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), } } + +// minTxFeesChecker will be executed only if the feemarket module is disabled. +// In this case, the auth module's DeductFeeDecorator is executed, and +// we use the minTxFeesChecker to enforce the minimum transaction fees. +// Min tx fees are calculated as gas_limit * feemarket_min_base_gas_price +func minTxFeesChecker(ctx sdk.Context, tx sdk.Tx, feemarketKp feemarketkeeper.Keeper) (sdk.Coins, int64, error) { + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return nil, 0, sdkerrors.ErrTxDecode.Wrap("tx must be FeeTx") + } + + // To keep the gentxs with zero fees, we need to skip the validation in the first block + if ctx.BlockHeight() == 0 { + return feeTx.GetFee(), 0, nil + } + + feeMarketParams, err := feemarketKp.GetParams(ctx) + if err != nil { + return nil, 0, err + } + + feeRequired := sdk.NewCoins( + sdk.NewCoin( + feeMarketParams.FeeDenom, + feeMarketParams.MinBaseGasPrice.MulInt(math.NewIntFromUint64(feeTx.GetGas())).Ceil().RoundInt())) + + feeCoins := feeTx.GetFee() + if len(feeCoins) != 1 { + return nil, 0, fmt.Errorf( + "expected exactly one fee coin; got %s, required: %s", feeCoins.String(), feeRequired.String()) + } + + if !feeCoins.IsAnyGTE(feeRequired) { + return nil, 0, fmt.Errorf( + "not enough fees provided; got %s, required: %s", feeCoins.String(), feeRequired.String()) + } + + return feeTx.GetFee(), 0, nil +} diff --git a/app/genesis.go b/app/genesis.go index d534f5b32..d3a0115d7 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -4,6 +4,8 @@ import ( "encoding/json" "time" + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + "github.com/cosmos/ibc-go/modules/capability" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" icagenesistypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/genesis/types" @@ -41,12 +43,11 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - v3 "github.com/bandprotocol/chain/v3/app/upgrades/v3" + v3 "github.com/bandprotocol/chain/v3/app/upgrades/v3_mainnet" "github.com/bandprotocol/chain/v3/x/bandtss" bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" "github.com/bandprotocol/chain/v3/x/feeds" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" - globalfeetypes "github.com/bandprotocol/chain/v3/x/globalfee/types" "github.com/bandprotocol/chain/v3/x/oracle" oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" "github.com/bandprotocol/chain/v3/x/restake" @@ -74,7 +75,7 @@ func NewDefaultGenesisState(cdc codec.Codec) GenesisState { crisisGenesis := crisistypes.DefaultGenesisState() slashingGenesis := slashingtypes.DefaultGenesisState() icaGenesis := icagenesistypes.DefaultGenesis() - globalfeeGenesis := globalfeetypes.DefaultGenesisState() + feemarketGenesis := feemarkettypes.DefaultGenesisState() // Override the genesis parameters. authGenesis.Params.TxSizeCostPerByte = 5 stakingGenesis.Params.BondDenom = denom @@ -102,9 +103,12 @@ func NewDefaultGenesisState(cdc codec.Codec) GenesisState { AllowMessages: v3.ICAAllowMessages, } - globalfeeGenesis.Params.MinimumGasPrices = sdk.NewDecCoins( - sdk.NewDecCoinFromDec(denom, math.LegacyNewDecWithPrec(25, 4)), // 0.0025uband - ) + feemarketGenesis.Params.MaxBlockUtilization = 50_000_000 + feemarketGenesis.Params.MinBaseGasPrice = math.LegacyNewDecWithPrec(25, 4) // 0.0025uband + feemarketGenesis.Params.FeeDenom = denom + feemarketGenesis.Params.Enabled = false + + feemarketGenesis.State.BaseGasPrice = math.LegacyNewDecWithPrec(25, 4) // 0.0025uband return GenesisState{ authtypes.ModuleName: cdc.MustMarshalJSON(authGenesis), @@ -125,13 +129,13 @@ func NewDefaultGenesisState(cdc codec.Codec) GenesisState { ibctransafertypes.ModuleName: ibctransfer.AppModuleBasic{}.DefaultGenesis(cdc), icatypes.ModuleName: cdc.MustMarshalJSON(icaGenesis), ibcfeetypes.ModuleName: ibcfee.AppModuleBasic{}.DefaultGenesis(cdc), + feemarkettypes.ModuleName: cdc.MustMarshalJSON(feemarketGenesis), rollingseedtypes.ModuleName: rollingseed.AppModuleBasic{}.DefaultGenesis(cdc), oracletypes.ModuleName: oracle.AppModuleBasic{}.DefaultGenesis(cdc), tsstypes.ModuleName: tss.AppModuleBasic{}.DefaultGenesis(cdc), bandtsstypes.ModuleName: bandtss.AppModuleBasic{}.DefaultGenesis(cdc), feedstypes.ModuleName: feeds.AppModuleBasic{}.DefaultGenesis(cdc), tunneltypes.ModuleName: tunnel.AppModuleBasic{}.DefaultGenesis(cdc), - globalfeetypes.ModuleName: cdc.MustMarshalJSON(globalfeeGenesis), restaketypes.ModuleName: restake.AppModuleBasic{}.DefaultGenesis(cdc), } } diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index a7b8d02cf..07501ad48 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -1,9 +1,13 @@ package keepers import ( + "fmt" "os" "path/filepath" + feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper" + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" @@ -73,8 +77,6 @@ import ( "github.com/bandprotocol/chain/v3/x/feeds" feedskeeper "github.com/bandprotocol/chain/v3/x/feeds/keeper" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" - globalfeekeeper "github.com/bandprotocol/chain/v3/x/globalfee/keeper" - globalfeetypes "github.com/bandprotocol/chain/v3/x/globalfee/types" "github.com/bandprotocol/chain/v3/x/oracle" oraclekeeper "github.com/bandprotocol/chain/v3/x/oracle/keeper" oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" @@ -118,7 +120,7 @@ type AppKeepers struct { FeedsKeeper feedskeeper.Keeper TunnelKeeper tunnelkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper - GlobalFeeKeeper globalfeekeeper.Keeper + FeeMarketKeeper *feemarketkeeper.Keeper RestakeKeeper restakekeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly IBCKeeper *ibckeeper.Keeper @@ -378,9 +380,11 @@ func NewAppKeeper( // If evidence needs to be handled for the app, set routes in router here and seal appKeepers.EvidenceKeeper = *evidenceKeeper // GlobalFeeKeeper - appKeepers.GlobalFeeKeeper = globalfeekeeper.NewKeeper( + appKeepers.FeeMarketKeeper = feemarketkeeper.NewKeeper( appCodec, - appKeepers.keys[globalfeetypes.StoreKey], + appKeepers.keys[feemarkettypes.StoreKey], + appKeepers.AccountKeeper, + &DefaultFeemarketDenomResolver{}, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -585,3 +589,21 @@ func initParamsKeeper( return paramsKeeper } + +type DefaultFeemarketDenomResolver struct{} + +func (r *DefaultFeemarketDenomResolver) ConvertToDenom( + _ sdk.Context, + coin sdk.DecCoin, + denom string, +) (sdk.DecCoin, error) { + if coin.Denom == denom { + return coin, nil + } + + return sdk.DecCoin{}, fmt.Errorf("error resolving denom") +} + +func (r *DefaultFeemarketDenomResolver) ExtraDenoms(_ sdk.Context) ([]string, error) { + return []string{}, nil +} diff --git a/app/keepers/keys.go b/app/keepers/keys.go index 640c0e9a3..57d09fc47 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -1,6 +1,8 @@ package keepers import ( + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" @@ -26,7 +28,6 @@ import ( bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" - globalfeetypes "github.com/bandprotocol/chain/v3/x/globalfee/types" oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" restaketypes "github.com/bandprotocol/chain/v3/x/restake/types" rollingseedtypes "github.com/bandprotocol/chain/v3/x/rollingseed/types" @@ -57,7 +58,7 @@ func (appKeepers *AppKeepers) GenerateKeys() { authzkeeper.StoreKey, icahosttypes.StoreKey, oracletypes.StoreKey, - globalfeetypes.StoreKey, + feemarkettypes.StoreKey, ibcfeetypes.StoreKey, restaketypes.StoreKey, feedstypes.StoreKey, diff --git a/app/modules.go b/app/modules.go index 8e7409127..9075a90f6 100644 --- a/app/modules.go +++ b/app/modules.go @@ -1,6 +1,9 @@ package band import ( + feemarket "github.com/skip-mev/feemarket/x/feemarket" + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + "github.com/cosmos/ibc-go/modules/capability" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -56,8 +59,6 @@ import ( "github.com/bandprotocol/chain/v3/x/feeds" feedsclient "github.com/bandprotocol/chain/v3/x/feeds/client" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" - "github.com/bandprotocol/chain/v3/x/globalfee" - globalfeetypes "github.com/bandprotocol/chain/v3/x/globalfee/types" "github.com/bandprotocol/chain/v3/x/oracle" oracleclient "github.com/bandprotocol/chain/v3/x/oracle/client" oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" @@ -72,18 +73,20 @@ import ( ) var maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - icatypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - ibcfeetypes.ModuleName: nil, - bandtsstypes.ModuleName: nil, - restaketypes.ModuleName: nil, - tunneltypes.ModuleName: nil, + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + icatypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibcfeetypes.ModuleName: nil, + bandtsstypes.ModuleName: nil, + restaketypes.ModuleName: nil, + tunneltypes.ModuleName: nil, + feemarkettypes.ModuleName: nil, + feemarkettypes.FeeCollectorName: nil, } func appModules( @@ -160,7 +163,7 @@ func appModules( ), app.TransferModule, app.ICAModule, - globalfee.NewAppModule(app.GlobalFeeKeeper), + feemarket.NewAppModule(appCodec, *app.FeeMarketKeeper), ibcfee.NewAppModule(app.IBCFeeKeeper), restake.NewAppModule(appCodec, app.RestakeKeeper), feeds.NewAppModule(appCodec, app.FeedsKeeper), @@ -294,8 +297,8 @@ func orderBeginBlockers() []string { feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, + feemarkettypes.ModuleName, consensusparamtypes.ModuleName, - globalfeetypes.ModuleName, } } @@ -336,8 +339,8 @@ func orderEndBlockers() []string { paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, + feemarkettypes.ModuleName, consensusparamtypes.ModuleName, - globalfeetypes.ModuleName, } } @@ -371,12 +374,19 @@ func orderInitBlockers() []string { paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, + // 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 + feemarkettypes.ModuleName, consensusparamtypes.ModuleName, rollingseedtypes.ModuleName, oracletypes.ModuleName, tsstypes.ModuleName, bandtsstypes.ModuleName, - globalfeetypes.ModuleName, restaketypes.ModuleName, feedstypes.ModuleName, tunneltypes.ModuleName, diff --git a/app/post.go b/app/post.go index 009203243..be27d4753 100644 --- a/app/post.go +++ b/app/post.go @@ -1,14 +1,42 @@ package band 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" ) -// PostHandlerOptions are the options required for constructing PostHandlers. -type PostHandlerOptions struct{} +// PostHandlerOptions are the options required for constructing a FeeMarket PostHandler. +type PostHandlerOptions struct { + AccountKeeper feemarketpost.AccountKeeper + BankKeeper feemarketpost.BankKeeper + FeeMarketKeeper feemarketpost.FeeMarketKeeper +} -// NewPostHandler returns a PostHandler chain with decorators. +// NewPostHandler returns a PostHandler chain with the fee deduct decorator. func NewPostHandler(options PostHandlerOptions) (sdk.PostHandler, error) { - postDecorators := []sdk.PostDecorator{} + 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.FeeMarketKeeper, + ), + } + return sdk.ChainPostDecorators(postDecorators...), nil } diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go deleted file mode 100644 index 3fc0a08a3..000000000 --- a/app/upgrades/v3/constants.go +++ /dev/null @@ -1,94 +0,0 @@ -package v3 - -import ( - ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" - ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - - storetypes "cosmossdk.io/store/types" - "cosmossdk.io/x/feegrant" - - sdk "github.com/cosmos/cosmos-sdk/types" - vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - "github.com/cosmos/cosmos-sdk/x/authz" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/bandprotocol/chain/v3/app/upgrades" - bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" - feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" - globalfeetypes "github.com/bandprotocol/chain/v3/x/globalfee/types" - oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" - restaketypes "github.com/bandprotocol/chain/v3/x/restake/types" - rollingseedtypes "github.com/bandprotocol/chain/v3/x/rollingseed/types" - tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" - tunneltypes "github.com/bandprotocol/chain/v3/x/tunnel/types" -) - -// UpgradeName defines the on-chain upgrade name. -const ( - UpgradeName = "v3" - - // BlockMaxBytes is the max bytes for a block, 3mb - BlockMaxBytes = int64(3000000) - - // BlockMaxGas is the max gas allowed in a block - BlockMaxGas = int64(50000000) -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: storetypes.StoreUpgrades{ - Added: []string{ - globalfeetypes.StoreKey, - consensusparamtypes.StoreKey, - crisistypes.StoreKey, - ibcfeetypes.StoreKey, - restaketypes.StoreKey, - feedstypes.StoreKey, - rollingseedtypes.StoreKey, - bandtsstypes.StoreKey, - tsstypes.StoreKey, - tunneltypes.StoreKey, - }, - }, -} - -// TODO: Update ICA Allow messages -var ICAAllowMessages = []string{ - sdk.MsgTypeURL(&authz.MsgExec{}), - sdk.MsgTypeURL(&authz.MsgGrant{}), - sdk.MsgTypeURL(&authz.MsgRevoke{}), - sdk.MsgTypeURL(&banktypes.MsgSend{}), - sdk.MsgTypeURL(&banktypes.MsgMultiSend{}), - sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), - sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}), - sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), - sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), - sdk.MsgTypeURL(&feegrant.MsgGrantAllowance{}), - sdk.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), - sdk.MsgTypeURL(&govv1beta1.MsgVoteWeighted{}), - sdk.MsgTypeURL(&govv1beta1.MsgSubmitProposal{}), - sdk.MsgTypeURL(&govv1beta1.MsgDeposit{}), - sdk.MsgTypeURL(&govv1beta1.MsgVote{}), - // Change: add messages from Oracle module - sdk.MsgTypeURL(&oracletypes.MsgActivate{}), - sdk.MsgTypeURL(&oracletypes.MsgCreateDataSource{}), - sdk.MsgTypeURL(&oracletypes.MsgCreateOracleScript{}), - sdk.MsgTypeURL(&oracletypes.MsgEditDataSource{}), - sdk.MsgTypeURL(&oracletypes.MsgEditOracleScript{}), - sdk.MsgTypeURL(&oracletypes.MsgReportData{}), - sdk.MsgTypeURL(&oracletypes.MsgRequestData{}), - - sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), - sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), - sdk.MsgTypeURL(&vestingtypes.MsgCreateVestingAccount{}), - sdk.MsgTypeURL(&ibctransfertypes.MsgTransfer{}), -} diff --git a/app/upgrades/v3_mainnet/constants.go b/app/upgrades/v3_mainnet/constants.go new file mode 100644 index 000000000..ef8f3d1b1 --- /dev/null +++ b/app/upgrades/v3_mainnet/constants.go @@ -0,0 +1,102 @@ +package v3_mainnet + +import ( + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + + ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/feegrant" + + sdk "github.com/cosmos/cosmos-sdk/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/bandprotocol/chain/v3/app/upgrades" + bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" + restaketypes "github.com/bandprotocol/chain/v3/x/restake/types" + rollingseedtypes "github.com/bandprotocol/chain/v3/x/rollingseed/types" + tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" + tunneltypes "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +// UpgradeName defines the on-chain upgrade name. +const ( + UpgradeName = "v3" + + Denom = "uband" + + // BlockMaxBytes is the max bytes for a block, 3mb + BlockMaxBytes = int64(3_000_000) + + // BlockMaxGas is the max gas allowed in a block + BlockMaxGas = int64(50_000_000) +) + +var ( + Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{ + Added: []string{ + feemarkettypes.StoreKey, + consensusparamtypes.StoreKey, + crisistypes.StoreKey, + ibcfeetypes.StoreKey, + restaketypes.StoreKey, + feedstypes.StoreKey, + rollingseedtypes.StoreKey, + bandtsstypes.StoreKey, + tsstypes.StoreKey, + tunneltypes.StoreKey, + }, + }, + } + + ICAAllowMessages = []string{ + sdk.MsgTypeURL(&authz.MsgExec{}), + sdk.MsgTypeURL(&authz.MsgGrant{}), + sdk.MsgTypeURL(&authz.MsgRevoke{}), + sdk.MsgTypeURL(&banktypes.MsgSend{}), + sdk.MsgTypeURL(&banktypes.MsgMultiSend{}), + sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}), + sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), + sdk.MsgTypeURL(&feegrant.MsgGrantAllowance{}), + sdk.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), + sdk.MsgTypeURL(&govv1beta1.MsgVoteWeighted{}), + sdk.MsgTypeURL(&govv1beta1.MsgSubmitProposal{}), + sdk.MsgTypeURL(&govv1beta1.MsgDeposit{}), + sdk.MsgTypeURL(&govv1beta1.MsgVote{}), + // Change: add messages from Oracle module + sdk.MsgTypeURL(&oracletypes.MsgActivate{}), + sdk.MsgTypeURL(&oracletypes.MsgCreateDataSource{}), + sdk.MsgTypeURL(&oracletypes.MsgCreateOracleScript{}), + sdk.MsgTypeURL(&oracletypes.MsgEditDataSource{}), + sdk.MsgTypeURL(&oracletypes.MsgEditOracleScript{}), + sdk.MsgTypeURL(&oracletypes.MsgReportData{}), + sdk.MsgTypeURL(&oracletypes.MsgRequestData{}), + + sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), + sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), + sdk.MsgTypeURL(&vestingtypes.MsgCreateVestingAccount{}), + sdk.MsgTypeURL(&ibctransfertypes.MsgTransfer{}), + } + + // MinimumGasPrice is the minimum gas price for transactions + MinimumGasPrice = sdkmath.LegacyNewDecWithPrec(25, 4) // 0.0025uband +) diff --git a/app/upgrades/v3/upgrades.go b/app/upgrades/v3_mainnet/upgrades.go similarity index 87% rename from app/upgrades/v3/upgrades.go rename to app/upgrades/v3_mainnet/upgrades.go index b086cec38..81059ab96 100644 --- a/app/upgrades/v3/upgrades.go +++ b/app/upgrades/v3_mainnet/upgrades.go @@ -1,8 +1,10 @@ -package v3 +package v3_mainnet import ( "context" + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + cmttypes "github.com/cometbft/cometbft/types" icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" @@ -10,7 +12,6 @@ import ( ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" - sdkmath "cosmossdk.io/math" upgradetypes "cosmossdk.io/x/upgrade/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,7 +28,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/bandprotocol/chain/v3/app/keepers" - globalfeetypes "github.com/bandprotocol/chain/v3/x/globalfee/types" oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" ) @@ -122,9 +122,23 @@ func CreateUpgradeHandler( return nil, err } - err = keepers.GlobalFeeKeeper.SetParams(ctx, globalfeetypes.Params{ - MinimumGasPrices: sdk.DecCoins{sdk.NewDecCoinFromDec("uband", sdkmath.LegacyNewDecWithPrec(25, 4))}, - }) + feemarketParams := feemarkettypes.DefaultParams() + feemarketParams.MaxBlockUtilization = uint64(BlockMaxGas) + feemarketParams.MinBaseGasPrice = MinimumGasPrice + feemarketParams.FeeDenom = Denom + feemarketParams.Enabled = false + err = keepers.FeeMarketKeeper.SetParams(ctx, feemarketParams) + if err != nil { + return nil, err + } + + state, err := keepers.FeeMarketKeeper.GetState(ctx) + if err != nil { + return nil, err + } + + state.BaseGasPrice = MinimumGasPrice + err = keepers.FeeMarketKeeper.SetState(ctx, state) if err != nil { return nil, err } diff --git a/app/upgrades/v3/upgrades_test.go b/app/upgrades/v3_mainnet/upgrades_test.go similarity index 73% rename from app/upgrades/v3/upgrades_test.go rename to app/upgrades/v3_mainnet/upgrades_test.go index 9b41196bd..de60d8194 100644 --- a/app/upgrades/v3/upgrades_test.go +++ b/app/upgrades/v3_mainnet/upgrades_test.go @@ -1,22 +1,22 @@ -package v3_test +package v3_mainnet_test import ( "testing" + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" "github.com/stretchr/testify/suite" abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" - sdkmath "cosmossdk.io/math" upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" band "github.com/bandprotocol/chain/v3/app" - v3 "github.com/bandprotocol/chain/v3/app/upgrades/v3" + v3 "github.com/bandprotocol/chain/v3/app/upgrades/v3_mainnet" bandtesting "github.com/bandprotocol/chain/v3/testing" ) @@ -89,9 +89,24 @@ func postUpgradeChecks(s *UpgradeTestSuite) { s.Require().True(icaHostParams.HostEnabled) s.Require().Equal(v3.ICAAllowMessages, icaHostParams.AllowMessages) - // check global fee params - s.Require(). - Equal(sdk.DecCoins{sdk.NewDecCoinFromDec("uband", sdkmath.LegacyNewDecWithPrec(25, 4))}, s.app.GlobalFeeKeeper.GetParams(s.ctx).MinimumGasPrices) + // check feemarket params + feemarketParams, err := s.app.FeeMarketKeeper.GetParams(s.ctx) + s.Require().NoError(err) + s.Require().Equal(feemarkettypes.DefaultWindow, feemarketParams.Window) + s.Require().Equal(feemarkettypes.DefaultAlpha, feemarketParams.Alpha) + s.Require().Equal(feemarkettypes.DefaultBeta, feemarketParams.Beta) + s.Require().Equal(feemarkettypes.DefaultGamma, feemarketParams.Gamma) + s.Require().Equal(feemarkettypes.DefaultMinLearningRate, feemarketParams.MinLearningRate) + s.Require().Equal(feemarkettypes.DefaultMaxLearningRate, feemarketParams.MaxLearningRate) + s.Require().Equal(uint64(v3.BlockMaxGas), feemarketParams.MaxBlockUtilization) + s.Require().Equal(v3.MinimumGasPrice, feemarketParams.MinBaseGasPrice) + s.Require().Equal(v3.Denom, feemarketParams.FeeDenom) + s.Require().False(feemarketParams.Enabled) + + // check feemarket state + state, err := s.app.FeeMarketKeeper.GetState(s.ctx) + s.Require().NoError(err) + s.Require().Equal(v3.MinimumGasPrice, state.BaseGasPrice) } func (s *UpgradeTestSuite) ConfirmUpgradeSucceeded(upgradeName string, upgradeHeight int64) { diff --git a/app/upgrades/v3_testnet/constants.go b/app/upgrades/v3_testnet/constants.go new file mode 100644 index 000000000..e4d666126 --- /dev/null +++ b/app/upgrades/v3_testnet/constants.go @@ -0,0 +1,42 @@ +package v3_testnet + +import ( + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + + "github.com/bandprotocol/chain/v3/app/upgrades" +) + +// UpgradeName defines the on-chain upgrade name. +const ( + UpgradeName = "v3" + + Denom = "uband" + + // BlockMaxBytes is the max bytes for a block, 3mb + BlockMaxBytes = int64(3_000_000) + + // BlockMaxGas is the max gas allowed in a block + BlockMaxGas = int64(50_000_000) +) + +var ( + Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{ + Added: []string{ + feemarkettypes.StoreKey, + }, + Deleted: []string{ + // TODO: check if we can import store key from deleted local module + "globalfee", + }, + }, + } + + // MinimumGasPrice is the minimum gas price for transactions + MinimumGasPrice = sdkmath.LegacyNewDecWithPrec(25, 4) // 0.0025uband +) diff --git a/app/upgrades/v3_testnet/upgrades.go b/app/upgrades/v3_testnet/upgrades.go new file mode 100644 index 000000000..9236a89fb --- /dev/null +++ b/app/upgrades/v3_testnet/upgrades.go @@ -0,0 +1,109 @@ +package v3_testnet + +import ( + "context" + + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + + icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + + upgradetypes "cosmossdk.io/x/upgrade/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/bandprotocol/chain/v3/app/keepers" + oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(c context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Set param key table for params module migration + ctx := sdk.UnwrapSDKContext(c) + for _, subspace := range keepers.ParamsKeeper.GetSubspaces() { + var keyTable paramstypes.KeyTable + switch subspace.Name() { + // cosmos-sdk types + case authtypes.ModuleName: + keyTable = authtypes.ParamKeyTable() //nolint:staticcheck + case banktypes.ModuleName: + keyTable = banktypes.ParamKeyTable() //nolint:staticcheck + case stakingtypes.ModuleName: + keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck + case minttypes.ModuleName: + keyTable = minttypes.ParamKeyTable() //nolint:staticcheck + case distrtypes.ModuleName: + keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck + case slashingtypes.ModuleName: + keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck + case govtypes.ModuleName: + keyTable = govv1.ParamKeyTable() //nolint:staticcheck + case crisistypes.ModuleName: + keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck + // ibc types + case ibctransfertypes.ModuleName: + keyTable = ibctransfertypes.ParamKeyTable() + case ibcclienttypes.SubModuleName: + keyTable = ibcclienttypes.ParamKeyTable() + case ibcconnectiontypes.SubModuleName: + keyTable = ibcconnectiontypes.ParamKeyTable() + case icahosttypes.SubModuleName: + keyTable = icahosttypes.ParamKeyTable() + // band types + case oracletypes.ModuleName: + keyTable = oracletypes.ParamKeyTable() + default: + continue + } + + if !subspace.HasKeyTable() { + subspace.WithKeyTable(keyTable) + } + } + + vm, err := mm.RunMigrations(ctx, configurator, fromVM) + if err != nil { + return nil, err + } + + feemarketParams := feemarkettypes.DefaultParams() + feemarketParams.MaxBlockUtilization = uint64(BlockMaxGas) + feemarketParams.MinBaseGasPrice = MinimumGasPrice + feemarketParams.FeeDenom = Denom + feemarketParams.Enabled = false + err = keepers.FeeMarketKeeper.SetParams(ctx, feemarketParams) + if err != nil { + return nil, err + } + + state, err := keepers.FeeMarketKeeper.GetState(ctx) + if err != nil { + return nil, err + } + + state.BaseGasPrice = MinimumGasPrice + err = keepers.FeeMarketKeeper.SetState(ctx, state) + if err != nil { + return nil, err + } + + return vm, nil + } +} diff --git a/app/upgrades/v3_testnet/upgrades_test.go b/app/upgrades/v3_testnet/upgrades_test.go new file mode 100644 index 000000000..964cbe5eb --- /dev/null +++ b/app/upgrades/v3_testnet/upgrades_test.go @@ -0,0 +1,99 @@ +package v3_testnet_test + +import ( + "testing" + + feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" + "github.com/stretchr/testify/suite" + + abci "github.com/cometbft/cometbft/abci/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + + upgradetypes "cosmossdk.io/x/upgrade/types" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + + band "github.com/bandprotocol/chain/v3/app" + v3 "github.com/bandprotocol/chain/v3/app/upgrades/v3_testnet" + bandtesting "github.com/bandprotocol/chain/v3/testing" +) + +type UpgradeTestSuite struct { + suite.Suite + + app *band.BandApp + ctx sdk.Context +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (s *UpgradeTestSuite) SetupTest() { + dir := testutil.GetTempDir(s.T()) + s.app = bandtesting.SetupWithCustomHome(false, dir) + s.ctx = s.app.BaseApp.NewUncachedContext(false, cmtproto.Header{}) + + // Activate validators + for _, v := range bandtesting.Validators { + err := s.app.OracleKeeper.Activate(s.ctx, v.ValAddress) + s.Require().NoError(err) + } + + _, err := s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1}) + s.Require().NoError(err) + _, err = s.app.Commit() + s.Require().NoError(err) +} + +// Ensures the test does not error out. +func (s *UpgradeTestSuite) TestUpgrade() { + preUpgradeChecks(s) + + upgradeHeight := int64(2) + s.ConfirmUpgradeSucceeded(v3.UpgradeName, upgradeHeight) + + postUpgradeChecks(s) +} + +func preUpgradeChecks(s *UpgradeTestSuite) { +} + +func postUpgradeChecks(s *UpgradeTestSuite) { + // check the subspaces + for _, subspace := range s.app.ParamsKeeper.GetSubspaces() { + s.Require().True(subspace.HasKeyTable()) + } + + // check feemarket params + feemarketParams, err := s.app.FeeMarketKeeper.GetParams(s.ctx) + s.Require().NoError(err) + s.Require().Equal(feemarkettypes.DefaultWindow, feemarketParams.Window) + s.Require().Equal(feemarkettypes.DefaultAlpha, feemarketParams.Alpha) + s.Require().Equal(feemarkettypes.DefaultBeta, feemarketParams.Beta) + s.Require().Equal(feemarkettypes.DefaultGamma, feemarketParams.Gamma) + s.Require().Equal(feemarkettypes.DefaultMinLearningRate, feemarketParams.MinLearningRate) + s.Require().Equal(feemarkettypes.DefaultMaxLearningRate, feemarketParams.MaxLearningRate) + s.Require().Equal(uint64(v3.BlockMaxGas), feemarketParams.MaxBlockUtilization) + s.Require().Equal(v3.MinimumGasPrice, feemarketParams.MinBaseGasPrice) + s.Require().Equal(v3.Denom, feemarketParams.FeeDenom) + s.Require().False(feemarketParams.Enabled) + + // check feemarket state + state, err := s.app.FeeMarketKeeper.GetState(s.ctx) + s.Require().NoError(err) + s.Require().Equal(v3.MinimumGasPrice, state.BaseGasPrice) +} + +func (s *UpgradeTestSuite) ConfirmUpgradeSucceeded(upgradeName string, upgradeHeight int64) { + plan := upgradetypes.Plan{Name: upgradeName, Height: upgradeHeight} + err := s.app.AppKeepers.UpgradeKeeper.ScheduleUpgrade(s.ctx, plan) + s.Require().NoError(err) + _, err = s.app.AppKeepers.UpgradeKeeper.GetUpgradePlan(s.ctx) + s.Require().NoError(err) + + s.ctx = s.ctx.WithBlockHeight(upgradeHeight) + _, err = s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.ctx.BlockHeight()}) + s.Require().NoError(err) +} diff --git a/go.mod b/go.mod index ac696372e..6a529c112 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/bandprotocol/chain/v3 -go 1.22.4 +go 1.22.6 toolchain go1.22.10 @@ -44,6 +44,7 @@ require ( github.com/peterbourgon/diskv v2.0.1+incompatible github.com/prometheus/client_golang v1.20.5 github.com/skip-mev/block-sdk/v2 v2.1.5 + github.com/skip-mev/feemarket v1.1.1 github.com/spf13/cast v1.7.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -93,8 +94,8 @@ require ( github.com/cosmos/iavl v1.2.2 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect - github.com/creachadair/atomicfile v0.3.1 // indirect - github.com/creachadair/tomledit v0.0.24 // indirect + github.com/creachadair/atomicfile v0.3.3 // indirect + github.com/creachadair/tomledit v0.0.26 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect @@ -102,7 +103,7 @@ require ( github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/dvsekhvalnov/jose2go v1.6.0 // indirect + github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -111,7 +112,7 @@ require ( github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect diff --git a/go.sum b/go.sum index 99b486388..0e59d6d4d 100644 --- a/go.sum +++ b/go.sum @@ -398,10 +398,12 @@ github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFg github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= -github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= -github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= -github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= +github.com/creachadair/atomicfile v0.3.3 h1:yJlDq8qk9QmD/6ol+jq1X4bcoLNVdYq95+owOnauziE= +github.com/creachadair/atomicfile v0.3.3/go.mod h1:X1r9P4wigJlGkYJO1HXZREdkVn+b1yHrsBBMLSj7tak= +github.com/creachadair/mtest v0.0.0-20231015022703-31f2ea539dce h1:BFjvg2Oq88/2DOcUFu1ScIwKUn7KJYYvLr6AeuCJD54= +github.com/creachadair/mtest v0.0.0-20231015022703-31f2ea539dce/go.mod h1:okn1ft6DY+qjPmnvYynyq7ufIQKJ2x2qwOCJZecei1k= +github.com/creachadair/tomledit v0.0.26 h1:MoDdgHIHZ5PctBVsAZDjxdxreWUEa9ObPKTRkk5PPwA= +github.com/creachadair/tomledit v0.0.26/go.mod h1:SJi1OxKpMyR141tq1lzsbPtIg3j8TeVPM/ZftfieD7o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -432,8 +434,8 @@ github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:Htrtb github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY= -github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/dvsekhvalnov/jose2go v1.7.0 h1:bnQc8+GMnidJZA8zc6lLEAb4xNrIqHwO+9TzqvtQZPo= +github.com/dvsekhvalnov/jose2go v1.7.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= @@ -497,8 +499,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -1004,6 +1006,10 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skip-mev/block-sdk/v2 v2.1.5 h1:3uoYG2ayP253wiohBPKdD3LrkJGd1Kgw914mmI1ZyOI= github.com/skip-mev/block-sdk/v2 v2.1.5/go.mod h1:E8SvITZUdxkes3gI3+kgESZL+NLffkcLKnowUgYTOf4= +github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610 h1:4JlsiRVt/YZOvrKH525T7sZXgEWUEjqSDMwE6fXNbdo= +github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610/go.mod h1:kB8gFZX07CyJnw8q9iEZijI3qJTIe1K/Y++P5VGkrcg= +github.com/skip-mev/feemarket v1.1.1 h1:L34K7N2J6o635kzNYRAvQ93+hAFtSiJ2t03jmaNx0zw= +github.com/skip-mev/feemarket v1.1.1/go.mod h1:DUa6djUsTeMOrbrcIZqWSVxU9IZNCXp96ruaojyBNpc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= diff --git a/testing/tx_helpers.go b/testing/tx_helpers.go index 8942b041d..894e9711d 100644 --- a/testing/tx_helpers.go +++ b/testing/tx_helpers.go @@ -3,6 +3,7 @@ package testing // Copy from https://github.com/cosmos/cosmos-sdk/blob/v0.50.9/testutil/sims/tx_helpers.go to add time in block header and block events import ( "context" + "fmt" "math/rand" "testing" "time" @@ -146,6 +147,8 @@ func SignCheckDeliver( require.Equal(t, 1, len(resBlock.TxResults)) txResult := resBlock.TxResults[0] finalizeSuccess := txResult.Code == 0 + fmt.Println("log", txResult.Log) + fmt.Println("info", txResult.Info) if expPass { require.True(t, finalizeSuccess) } else { diff --git a/x/bank/app_test.go b/x/bank/app_test.go index b920eea61..c54ad6890 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -78,6 +78,8 @@ func TestAppTestSuite(t *testing.T) { func (s *AppTestSuite) SetupTest() { dir := testutil.GetTempDir(s.T()) + + band.UseFeeMarketDecorator = false s.app = bandtesting.SetupWithCustomHome(false, dir) ctx := s.app.BaseApp.NewUncachedContext(false, cmtproto.Header{}) @@ -86,12 +88,14 @@ func (s *AppTestSuite) SetupTest() { _, err = s.app.Commit() s.Require().NoError(err) - params, err := s.app.SlashingKeeper.GetParams(ctx) + // Set new sign window + slashingParams, err := s.app.SlashingKeeper.GetParams(ctx) s.Require().NoError(err) - // Set new sign window - params.SignedBlocksWindow = 2 - params.MinSignedPerWindow = math.LegacyNewDecWithPrec(5, 1) + slashingParams.SignedBlocksWindow = 2 + slashingParams.MinSignedPerWindow = math.LegacyNewDecWithPrec(5, 1) + err = s.app.SlashingKeeper.SetParams(ctx, slashingParams) + s.Require().NoError(err) // Add Missed validator res1 := s.app.AccountKeeper.GetAccount(ctx, bandtesting.MissedValidator.Address) @@ -102,9 +106,6 @@ func (s *AppTestSuite) SetupTest() { txConfig := moduletestutil.MakeTestTxConfig() - err = s.app.SlashingKeeper.SetParams(ctx, params) - s.Require().NoError(err) - msg, err := stakingtypes.NewMsgCreateValidator( sdk.ValAddress(bandtesting.MissedValidator.Address).String(), bandtesting.MissedValidator.PubKey, diff --git a/x/globalfee/README.md b/x/globalfee/README.md deleted file mode 100644 index dcda53fe1..000000000 --- a/x/globalfee/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Global fee module - -This module is the fork version of globalfee module from [Gaia](https://github.com/cosmos/gaia) and [TGrade](https://github.com/confio/tgrade) with modifications to use with the Oracle module and Cosmos-SDK 0.47.x version. All credits and big thanks go to the original authors. - diff --git a/x/globalfee/client/cli/query.go b/x/globalfee/client/cli/query.go deleted file mode 100644 index e39fed206..000000000 --- a/x/globalfee/client/cli/query.go +++ /dev/null @@ -1,48 +0,0 @@ -package cli - -import ( - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -func GetQueryCmd() *cobra.Command { - queryCmd := &cobra.Command{ - Use: types.ModuleName, - Short: "Querying commands for the globalfee module", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - queryCmd.AddCommand( - GetQueryCmdParams(), - ) - return queryCmd -} - -func GetQueryCmdParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "Show params", - Long: "Show parameter of globalfee module", - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - return clientCtx.PrintProto(res) - }, - } - flags.AddQueryFlagsToCmd(cmd) - return cmd -} diff --git a/x/globalfee/feechecker/feechecker.go b/x/globalfee/feechecker/feechecker.go deleted file mode 100644 index 32a303437..000000000 --- a/x/globalfee/feechecker/feechecker.go +++ /dev/null @@ -1,142 +0,0 @@ -package feechecker - -import ( - sdkmath "cosmossdk.io/math" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - - bandtsskeeper "github.com/bandprotocol/chain/v3/x/bandtss/keeper" - feedskeeper "github.com/bandprotocol/chain/v3/x/feeds/keeper" - feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" - "github.com/bandprotocol/chain/v3/x/globalfee/keeper" - oraclekeeper "github.com/bandprotocol/chain/v3/x/oracle/keeper" - tsskeeper "github.com/bandprotocol/chain/v3/x/tss/keeper" - tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" -) - -type FeeChecker struct { - cdc codec.Codec - - AuthzKeeper *authzkeeper.Keeper - OracleKeeper *oraclekeeper.Keeper - GlobalfeeKeeper *keeper.Keeper - StakingKeeper *stakingkeeper.Keeper - TSSKeeper *tsskeeper.Keeper - BandtssKeeper *bandtsskeeper.Keeper - FeedsKeeper *feedskeeper.Keeper - - TSSMsgServer tsstypes.MsgServer - FeedsMsgServer feedstypes.MsgServer -} - -func NewFeeChecker( - cdc codec.Codec, - authzKeeper *authzkeeper.Keeper, - oracleKeeper *oraclekeeper.Keeper, - globalfeeKeeper *keeper.Keeper, - stakingKeeper *stakingkeeper.Keeper, - tssKeeper *tsskeeper.Keeper, - bandtssKeeper *bandtsskeeper.Keeper, - feedsKeeper *feedskeeper.Keeper, -) FeeChecker { - tssMsgServer := tsskeeper.NewMsgServerImpl(tssKeeper) - feedsMsgServer := feedskeeper.NewMsgServerImpl(*feedsKeeper) - - return FeeChecker{ - cdc: cdc, - AuthzKeeper: authzKeeper, - OracleKeeper: oracleKeeper, - GlobalfeeKeeper: globalfeeKeeper, - StakingKeeper: stakingKeeper, - TSSKeeper: tssKeeper, - BandtssKeeper: bandtssKeeper, - FeedsKeeper: feedsKeeper, - TSSMsgServer: tssMsgServer, - FeedsMsgServer: feedsMsgServer, - } -} - -// CheckTxFee is responsible for verifying whether a transaction contains the necessary fee. -func (fc FeeChecker) CheckTxFee( - ctx sdk.Context, - tx sdk.Tx, -) (sdk.Coins, int64, error) { - feeTx, ok := tx.(sdk.FeeTx) - if !ok { - return nil, 0, sdkerrors.ErrTxDecode.Wrap("Tx must be a FeeTx") - } - - feeCoins := feeTx.GetFee() - gas := feeTx.GetGas() - bondDenom, err := fc.StakingKeeper.BondDenom(ctx) - if err != nil { - return nil, 0, err - } - priority := getTxPriority(feeCoins, int64(gas), bondDenom) - - // Ensure that the provided fees meet minimum-gas-prices and globalFees, - // if this is a CheckTx. This is only for local mempool purposes, and thus - // is only ran on check tx. - if !ctx.IsCheckTx() { - return feeCoins, priority, nil - } - - minGasPrices := getMinGasPrices(ctx) - globalMinGasPrices, err := fc.GetGlobalMinGasPrices(ctx) - if err != nil { - return nil, 0, err - } - - allGasPrices := CombinedGasPricesRequirement(minGasPrices, globalMinGasPrices) - - // Calculate all fees from all gas prices - var allFees sdk.Coins - if !allGasPrices.IsZero() { - glDec := sdkmath.LegacyNewDec(int64(gas)) - for _, gp := range allGasPrices { - if !gp.IsZero() { - fee := gp.Amount.Mul(glDec) - allFees = append(allFees, sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())) - } - } - } - - if !allFees.IsZero() && !feeCoins.IsAnyGTE(allFees) { - return nil, 0, sdkerrors.ErrInsufficientFee.Wrapf( - "insufficient fees; got: %s required: %s", - feeCoins, - allFees, - ) - } - - return feeCoins, priority, nil -} - -// GetGlobalMinGasPrices returns global min gas prices -func (fc FeeChecker) GetGlobalMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error) { - globalMinGasPrices := fc.GlobalfeeKeeper.GetParams(ctx).MinimumGasPrices - if len(globalMinGasPrices) != 0 { - return globalMinGasPrices.Sort(), nil - } - // global fee is empty set, set global fee to 0uband (bondDenom) - globalMinGasPrices, err := fc.DefaultZeroGlobalFee(ctx) - if err != nil { - return globalMinGasPrices, err - } - - return globalMinGasPrices.Sort(), nil -} - -// DefaultZeroGlobalFee returns a zero coin with the staking module bond denom -func (fc FeeChecker) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, error) { - bondDenom, err := fc.StakingKeeper.BondDenom(ctx) - if err != nil { - return nil, err - } - - return []sdk.DecCoin{sdk.NewDecCoinFromDec(bondDenom, sdkmath.LegacyNewDec(0))}, nil -} diff --git a/x/globalfee/feechecker/feechecker_test.go b/x/globalfee/feechecker/feechecker_test.go deleted file mode 100644 index cf2f61256..000000000 --- a/x/globalfee/feechecker/feechecker_test.go +++ /dev/null @@ -1,161 +0,0 @@ -package feechecker_test - -import ( - "testing" - "time" - - "github.com/stretchr/testify/suite" - protov2 "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/protoadapt" - - abci "github.com/cometbft/cometbft/abci/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - - sdkmath "cosmossdk.io/math" - - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/authz" - - bandtesting "github.com/bandprotocol/chain/v3/testing" - bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" - feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" - "github.com/bandprotocol/chain/v3/x/globalfee/feechecker" - oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" - tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" -) - -var ( - BasicCalldata = []byte("BASIC_CALLDATA") - BasicClientID = "BASIC_CLIENT_ID" -) - -type StubTx struct { - sdk.Tx - sdk.FeeTx - Msgs []sdk.Msg - GasPrices sdk.DecCoins -} - -func (st *StubTx) GetMsgs() []sdk.Msg { - return st.Msgs -} - -func (st *StubTx) GetMsgsV2() (ms []protov2.Message, err error) { - for _, msg := range st.Msgs { - ms = append(ms, protoadapt.MessageV2Of(msg)) - } - - return -} - -func (st *StubTx) GetGas() uint64 { - return 1000000 -} - -func (st *StubTx) GetFee() sdk.Coins { - fees := make(sdk.Coins, len(st.GasPrices)) - - // Determine the fees by multiplying each gas prices - glDec := sdkmath.LegacyNewDec(int64(st.GetGas())) - for i, gp := range st.GasPrices { - fee := gp.Amount.Mul(glDec) - fees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) - } - - return fees -} - -type FeeCheckerTestSuite struct { - suite.Suite - FeeChecker feechecker.FeeChecker - ctx sdk.Context - requestID oracletypes.RequestID -} - -func (suite *FeeCheckerTestSuite) SetupTest() { - dir := testutil.GetTempDir(suite.T()) - app := bandtesting.SetupWithCustomHome(false, dir) - ctx := app.BaseApp.NewUncachedContext(false, cmtproto.Header{}) - - // Activate validators - for _, v := range bandtesting.Validators { - err := app.OracleKeeper.Activate(ctx, v.ValAddress) - suite.Require().NoError(err) - } - - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) - suite.Require().NoError(err) - _, err = app.Commit() - suite.Require().NoError(err) - - suite.ctx = ctx.WithBlockHeight(999). - WithIsCheckTx(true). - WithMinGasPrices(sdk.DecCoins{{Denom: "uband", Amount: sdkmath.LegacyNewDecWithPrec(1, 4)}}) - - err = app.OracleKeeper.GrantReporter(suite.ctx, bandtesting.Validators[0].ValAddress, bandtesting.Alice.Address) - suite.Require().NoError(err) - - expiration := ctx.BlockTime().Add(1000 * time.Hour) - - msgTypeURLs := []sdk.Msg{&tsstypes.MsgSubmitDEs{}, &feedstypes.MsgSubmitSignalPrices{}} - for _, msg := range msgTypeURLs { - err = app.AuthzKeeper.SaveGrant( - ctx, - bandtesting.Alice.Address, - bandtesting.Validators[0].Address, - authz.NewGenericAuthorization(sdk.MsgTypeURL(msg)), - &expiration, - ) - suite.Require().NoError(err) - } - - // mock setup bandtss module - app.BandtssKeeper.SetCurrentGroup(ctx, bandtsstypes.NewCurrentGroup(1, ctx.BlockTime())) - app.BandtssKeeper.SetMember(ctx, bandtsstypes.Member{ - Address: bandtesting.Validators[0].Address.String(), - IsActive: true, - GroupID: 1, - }) - - req := oracletypes.NewRequest( - 1, - BasicCalldata, - []sdk.ValAddress{bandtesting.Validators[0].ValAddress}, - 1, - 1, - bandtesting.ParseTime(0), - "", - nil, - nil, - 0, - 0, - bandtesting.FeePayer.Address.String(), - bandtesting.Coins100000000uband, - ) - suite.requestID = app.OracleKeeper.AddRequest(suite.ctx, req) - - suite.FeeChecker = feechecker.NewFeeChecker( - app.AppCodec(), - &app.AuthzKeeper, - &app.OracleKeeper, - &app.GlobalFeeKeeper, - app.StakingKeeper, - app.TSSKeeper, - &app.BandtssKeeper, - &app.FeedsKeeper, - ) -} - -func (suite *FeeCheckerTestSuite) TestDefaultZeroGlobalFee() { - coins, err := suite.FeeChecker.DefaultZeroGlobalFee(suite.ctx) - - suite.Require().Equal(1, len(coins)) - suite.Require().Equal("uband", coins[0].Denom) - suite.Require().Equal(sdkmath.LegacyNewDec(0), coins[0].Amount) - suite.Require().NoError(err) -} - -func TestFeeCheckerTestSuite(t *testing.T) { - suite.Run(t, new(FeeCheckerTestSuite)) -} diff --git a/x/globalfee/feechecker/utils.go b/x/globalfee/feechecker/utils.go deleted file mode 100644 index c44c0bca2..000000000 --- a/x/globalfee/feechecker/utils.go +++ /dev/null @@ -1,68 +0,0 @@ -package feechecker - -import ( - "math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - oraclekeeper "github.com/bandprotocol/chain/v3/x/oracle/keeper" - oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" -) - -// getTxPriority returns priority of the provided fee based on gas prices of uband -func getTxPriority(fee sdk.Coins, gas int64, denom string) int64 { - ok, c := fee.Find(denom) - if !ok { - return 0 - } - - // multiplied by 10000 first to support our current standard (0.0025) because priority is int64. - // otherwise, if gas_price < 1, the priority will be 0. - priority := int64(math.MaxInt64) - gasPrice := c.Amount.MulRaw(10000).QuoRaw(gas) - if gasPrice.IsInt64() { - priority = gasPrice.Int64() - } - - return priority -} - -// getMinGasPrices will also return sorted dec coins -func getMinGasPrices(ctx sdk.Context) sdk.DecCoins { - return ctx.MinGasPrices().Sort() -} - -// CombinedGasPricesRequirement will combine the global min_gas_prices and min_gas_prices. Both globalMinGasPrices and minGasPrices must be valid -func CombinedGasPricesRequirement(globalMinGasPrices, minGasPrices sdk.DecCoins) sdk.DecCoins { - // return globalMinGasPrices if minGasPrices has not been set - if minGasPrices.Empty() { - return globalMinGasPrices - } - // return minGasPrices if globalMinGasPrices is empty - if globalMinGasPrices.Empty() { - return minGasPrices - } - - // if min_gas_price denom is in globalfee, and the amount is higher than globalfee, add min_gas_price to allGasPrices - var allGasPrices sdk.DecCoins - for _, gmgp := range globalMinGasPrices { - // min_gas_price denom in global fee - mgp := minGasPrices.AmountOf(gmgp.Denom) - if mgp.GT(gmgp.Amount) { - allGasPrices = append(allGasPrices, sdk.NewDecCoinFromDec(gmgp.Denom, mgp)) - } else { - allGasPrices = append(allGasPrices, sdk.NewDecCoinFromDec(gmgp.Denom, gmgp.Amount)) - } - } - - return allGasPrices.Sort() -} - -func checkValidMsgReport(ctx sdk.Context, oracleKeeper *oraclekeeper.Keeper, msg *oracletypes.MsgReportData) error { - validator, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return err - } - - return oracleKeeper.CheckValidReport(ctx, msg.RequestID, validator, msg.RawReports) -} diff --git a/x/globalfee/feechecker/utils_test.go b/x/globalfee/feechecker/utils_test.go deleted file mode 100644 index 64595625c..000000000 --- a/x/globalfee/feechecker/utils_test.go +++ /dev/null @@ -1,127 +0,0 @@ -package feechecker_test - -import ( - "testing" - - "github.com/stretchr/testify/suite" - - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/bandprotocol/chain/v3/x/globalfee/feechecker" -) - -type utilsTestSuite struct { - suite.Suite -} - -func TestUtilsTestSuite(t *testing.T) { - suite.Run(t, new(utilsTestSuite)) -} - -func (s *utilsTestSuite) TestCombinedGasPricesRequirement() { - zeroCoin1 := sdk.NewDecCoin("photon", math.ZeroInt()) - zeroCoin2 := sdk.NewDecCoin("stake", math.ZeroInt()) - zeroCoin3 := sdk.NewDecCoin("quark", math.ZeroInt()) - coin1 := sdk.NewDecCoin("photon", math.NewInt(1)) - coin2 := sdk.NewDecCoin("stake", math.NewInt(2)) - coin1High := sdk.NewDecCoin("photon", math.NewInt(10)) - coin2High := sdk.NewDecCoin("stake", math.NewInt(20)) - coinNewDenom1 := sdk.NewDecCoin("Newphoton", math.NewInt(1)) - coinNewDenom2 := sdk.NewDecCoin("Newstake", math.NewInt(1)) - // coins must be valid !!! and sorted!!! - coinsEmpty := sdk.DecCoins{} - coinsNonEmpty := sdk.DecCoins{coin1, coin2}.Sort() - coinsNonEmptyHigh := sdk.DecCoins{coin1High, coin2High}.Sort() - coinsNonEmptyOneHigh := sdk.DecCoins{coin1High, coin2}.Sort() - coinsNewDenom := sdk.DecCoins{coinNewDenom1, coinNewDenom2}.Sort() - coinsNewOldDenom := sdk.DecCoins{coin1, coinNewDenom1}.Sort() - coinsNewOldDenomHigh := sdk.DecCoins{coin1High, coinNewDenom1}.Sort() - coinsCointainZero := sdk.DecCoins{coin1, zeroCoin2}.Sort() - coinsCointainZeroNewDenom := sdk.DecCoins{coin1, zeroCoin3}.Sort() - coinsAllZero := sdk.DecCoins{zeroCoin1, zeroCoin2}.Sort() - tests := map[string]struct { - cGlobal sdk.DecCoins - c sdk.DecCoins - combined sdk.DecCoins - }{ - "global price empty, min price empty, combined price empty": { - cGlobal: coinsEmpty, - c: coinsEmpty, - combined: coinsEmpty, - }, - "global price empty, min price nonempty, combined price nonempty": { - cGlobal: coinsEmpty, - c: coinsNonEmpty, - combined: coinsNonEmpty, - }, - "global price nonempty, min price nonempty, combined price nonempty": { - cGlobal: coinsNonEmpty, - c: coinsNonEmpty, - combined: coinsNonEmpty, - }, - "global price and min price have overlapping denom, min prices amounts are all higher": { - cGlobal: coinsNonEmpty, - c: coinsNonEmptyHigh, - combined: coinsNonEmptyHigh, - }, - "global price and min price have overlapping denom, one of min prices amounts is higher": { - cGlobal: coinsNonEmpty, - c: coinsNonEmptyOneHigh, - combined: coinsNonEmptyOneHigh, - }, - "global price and min price have no overlapping denom, combined price = global price": { - cGlobal: coinsNonEmpty, - c: coinsNewDenom, - combined: coinsNonEmpty, - }, - "global prices and min prices have partial overlapping denom, min price amount <= global price amount, combined prices = global prices": { - cGlobal: coinsNonEmpty, - c: coinsNewOldDenom, - combined: coinsNonEmpty, - }, - "global prices and min prices have partial overlapping denom, one min price amount > global price amount, combined price = overlapping highest": { - cGlobal: coinsNonEmpty, - c: coinsNewOldDenomHigh, - combined: sdk.DecCoins{coin1High, coin2}, - }, - "global prices have zero prices, min prices have overlapping non-zero prices, combined prices = overlapping highest": { - cGlobal: coinsCointainZero, - c: coinsNonEmpty, - combined: sdk.DecCoins{coin1, coin2}, - }, - "global prices have zero prices, min prices have overlapping zero prices": { - cGlobal: coinsCointainZero, - c: coinsCointainZero, - combined: coinsCointainZero, - }, - "global prices have zero prices, min prices have non-overlapping zero prices": { - cGlobal: coinsCointainZero, - c: coinsCointainZeroNewDenom, - combined: coinsCointainZero, - }, - "global prices are all zero prices, min prices have overlapping zero prices": { - cGlobal: coinsAllZero, - c: coinsAllZero, - combined: coinsAllZero, - }, - "global prices are all zero prices, min prices have overlapping non-zero prices, combined price = overlapping highest": { - cGlobal: coinsAllZero, - c: coinsCointainZeroNewDenom, - combined: sdk.DecCoins{coin1, zeroCoin2}, - }, - "global prices are all zero prices, prices have one overlapping non-zero price": { - cGlobal: coinsAllZero, - c: coinsCointainZero, - combined: coinsCointainZero, - }, - } - - for name, test := range tests { - s.Run(name, func() { - allPrices := feechecker.CombinedGasPricesRequirement(test.cGlobal, test.c) - s.Require().Equal(test.combined, allPrices) - }) - } -} diff --git a/x/globalfee/genesis_test.go b/x/globalfee/genesis_test.go deleted file mode 100644 index 99adc58e8..000000000 --- a/x/globalfee/genesis_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package globalfee - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" -) - -func TestDefaultGenesis(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig() - gotJSON := AppModuleBasic{}.DefaultGenesis(encCfg.Codec) - assert.JSONEq(t, `{"params":{"minimum_gas_prices":[]}}`, string(gotJSON)) -} - -func TestValidateGenesis(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig() - specs := map[string]struct { - src string - expErr bool - }{ - "all good": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, - }, - "empty minimum": { - src: `{"params":{"minimum_gas_prices":[]}}`, - }, - "minimum not set": { - src: `{"params":{}}`, - }, - "zero amount not allowed": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"0"}]}}`, - expErr: true, - }, - "duplicate denoms not allowed": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"},{"denom":"ALX", "amount":"2"}]}}`, - expErr: true, - }, - "negative amounts not allowed": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"-1"}]}}`, - expErr: true, - }, - "denom must be sorted": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ZLX", "amount":"1"},{"denom":"ALX", "amount":"2"}]}}`, - expErr: true, - }, - "sorted denoms is allowed": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"},{"denom":"ZLX", "amount":"2"}]}}`, - expErr: false, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - gotErr := AppModuleBasic{}.ValidateGenesis(encCfg.Codec, nil, []byte(spec.src)) - if spec.expErr { - require.Error(t, gotErr) - return - } - require.NoError(t, gotErr) - }) - } -} diff --git a/x/globalfee/keeper/genesis.go b/x/globalfee/keeper/genesis.go deleted file mode 100644 index 4d4f3efbe..000000000 --- a/x/globalfee/keeper/genesis.go +++ /dev/null @@ -1,20 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -// InitGenesis new globalfee genesis -func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { - if err := k.SetParams(ctx, data.Params); err != nil { - panic(err) - } -} - -// ExportGenesis returns a GenesisState for a given context. -func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - params := k.GetParams(ctx) - return types.NewGenesisState(params) -} diff --git a/x/globalfee/keeper/genesis_test.go b/x/globalfee/keeper/genesis_test.go deleted file mode 100644 index 617cc074e..000000000 --- a/x/globalfee/keeper/genesis_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/suite" - - "cosmossdk.io/math" - storetypes "cosmossdk.io/store/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/bandprotocol/chain/v3/x/globalfee" - "github.com/bandprotocol/chain/v3/x/globalfee/keeper" - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -type GenesisTestSuite struct { - suite.Suite - - sdkCtx sdk.Context - keeper keeper.Keeper - cdc codec.BinaryCodec - key *storetypes.KVStoreKey -} - -func TestGenesisTestSuite(t *testing.T) { - suite.Run(t, new(GenesisTestSuite)) -} - -func (s *GenesisTestSuite) SetupTest() { - key := storetypes.NewKVStoreKey(types.StoreKey) - testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(globalfee.AppModuleBasic{}) - - // gomock initializations - s.cdc = codec.NewProtoCodec(encCfg.InterfaceRegistry) - s.sdkCtx = testCtx.Ctx - s.key = key - - s.keeper = keeper.NewKeeper(s.cdc, key, authtypes.NewModuleAddress(govtypes.ModuleName).String()) -} - -func (s *GenesisTestSuite) TestImportExportGenesis() { - specs := map[string]struct { - src string - exp types.GenesisState - }{ - "single fee": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, - exp: types.GenesisState{ - Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", math.NewInt(1)))}, - }, - }, - "multiple fee options": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}, {"denom":"BLX", "amount":"0.001"}]}}`, - exp: types.GenesisState{ - Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", math.NewInt(1)), - sdk.NewDecCoinFromDec("BLX", math.LegacyNewDecWithPrec(1, 3)))}, - }, - }, - "no fee set": { - src: `{"params":{}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: nil}}, - }, - } - for name, spec := range specs { - s.Run(name, func() { - genesisState := spec.exp - s.keeper.InitGenesis(s.sdkCtx, &genesisState) - - params := s.keeper.GetParams(s.sdkCtx) - s.Require().Equal(genesisState.Params, params) - - genesisState2 := s.keeper.ExportGenesis(s.sdkCtx) - s.Require().Equal(&genesisState, genesisState2) - }) - } -} diff --git a/x/globalfee/keeper/grpc_query.go b/x/globalfee/keeper/grpc_query.go deleted file mode 100644 index da6dea6b2..000000000 --- a/x/globalfee/keeper/grpc_query.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -var _ types.QueryServer = &Querier{} - -type Querier struct { - Keeper -} - -// Params return parameters of globalfee module -func (q Querier) Params(stdCtx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(stdCtx) - - return &types.QueryParamsResponse{ - Params: q.GetParams(ctx), - }, nil -} diff --git a/x/globalfee/keeper/grpc_query_test.go b/x/globalfee/keeper/grpc_query_test.go deleted file mode 100644 index e741edcee..000000000 --- a/x/globalfee/keeper/grpc_query_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "cosmossdk.io/math" - storetypes "cosmossdk.io/store/types" - - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/bandprotocol/chain/v3/x/globalfee/keeper" - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -func TestQueryParams(t *testing.T) { - specs := map[string]struct { - setupStore func(ctx sdk.Context, k keeper.Keeper) - expMin sdk.DecCoins - }{ - "one coin": { - setupStore: func(ctx sdk.Context, k keeper.Keeper) { - _ = k.SetParams(ctx, types.Params{ - MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", math.OneInt())), - }) - }, - expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", math.OneInt())), - }, - "multiple coins": { - setupStore: func(ctx sdk.Context, k keeper.Keeper) { - err := k.SetParams(ctx, types.Params{ - MinimumGasPrices: sdk.NewDecCoins( - sdk.NewDecCoin("ALX", math.OneInt()), - sdk.NewDecCoin("BLX", math.NewInt(2)), - ), - }) - require.NoError(t, err) - }, - expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", math.OneInt()), sdk.NewDecCoin("BLX", math.NewInt(2))), - }, - "no min gas price set": { - setupStore: func(ctx sdk.Context, k keeper.Keeper) { - err := k.SetParams(ctx, types.Params{}) - require.NoError(t, err) - }, - }, - "no param set": { - setupStore: func(ctx sdk.Context, k keeper.Keeper) { - }, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig() - key := storetypes.NewKVStoreKey(types.StoreKey) - ctx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")).Ctx - - k := keeper.NewKeeper( - encCfg.Codec, - key, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - q := keeper.Querier{Keeper: k} - spec.setupStore(ctx, k) - gotResp, gotErr := q.Params(ctx, nil) - - require.NoError(t, gotErr) - require.NotNil(t, gotResp) - assert.Equal(t, spec.expMin, gotResp.Params.MinimumGasPrices) - }) - } -} diff --git a/x/globalfee/keeper/keeper.go b/x/globalfee/keeper/keeper.go deleted file mode 100644 index ff061df59..000000000 --- a/x/globalfee/keeper/keeper.go +++ /dev/null @@ -1,60 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/log" - storetypes "cosmossdk.io/store/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -type Keeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec - - authority string -} - -func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, authority string) Keeper { - return Keeper{ - storeKey: storeKey, - cdc: cdc, - authority: authority, - } -} - -func (k *Keeper) GetAuthority() string { - return k.authority -} - -// SetParams sets the x/globalfee module parameters. -func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { - if err := p.Validate(); err != nil { - return err - } - - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&p) - store.Set(types.ParamsKeyPrefix, bz) - - return nil -} - -// GetParams returns the current x/globalfee module parameters. -func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKeyPrefix) - if bz == nil { - return p - } - - k.cdc.MustUnmarshal(bz, &p) - return p -} - -// Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) -} diff --git a/x/globalfee/keeper/keeper_test.go b/x/globalfee/keeper/keeper_test.go deleted file mode 100644 index d656d46b1..000000000 --- a/x/globalfee/keeper/keeper_test.go +++ /dev/null @@ -1,151 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/suite" - - "cosmossdk.io/math" - storetypes "cosmossdk.io/store/types" - - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/bandprotocol/chain/v3/x/globalfee" - "github.com/bandprotocol/chain/v3/x/globalfee/keeper" - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -type IntegrationTestSuite struct { - suite.Suite - - globalfeeKeeper keeper.Keeper - ctx sdk.Context - msgServer types.MsgServer -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} - -func (s *IntegrationTestSuite) SetupTest() { - encCfg := moduletestutil.MakeTestEncodingConfig(globalfee.AppModuleBasic{}) - key := storetypes.NewKVStoreKey(types.StoreKey) - testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - s.ctx = testCtx.Ctx - - s.globalfeeKeeper = keeper.NewKeeper( - encCfg.Codec, - key, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - s.Require().Equal(testCtx.Ctx.Logger().With("module", "x/"+types.ModuleName), - s.globalfeeKeeper.Logger(testCtx.Ctx)) - - err := s.globalfeeKeeper.SetParams(s.ctx, types.DefaultParams()) - s.Require().NoError(err) - - s.msgServer = keeper.NewMsgServerImpl(s.globalfeeKeeper) -} - -func (s *IntegrationTestSuite) TestParams() { - testCases := []struct { - name string - input types.Params - expectErr string - }{ - { - name: "set full valid params", - input: types.Params{ - MinimumGasPrices: sdk.NewDecCoins( - sdk.NewDecCoin("ALX", math.NewInt(1)), - sdk.NewDecCoinFromDec("BLX", math.LegacyNewDecWithPrec(1, 3)), - ), - }, - expectErr: "", - }, - { - name: "set empty coin", - input: types.Params{ - MinimumGasPrices: sdk.DecCoins(nil), - }, - expectErr: "", - }, - { - name: "set invalid denom", - input: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "1AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(1)), - }, - }, - }, - expectErr: "invalid denom", - }, - { - name: "set negative value", - input: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(-1)), - }, - }, - }, - expectErr: "is not positive", - }, - { - name: "set duplicated denom", - input: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(1)), - }, - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(2)), - }, - }, - }, - expectErr: "duplicate denomination", - }, - { - name: "set unsorted denom", - input: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "BBBB", - Amount: math.LegacyNewDecFromInt(math.NewInt(1)), - }, - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(2)), - }, - }, - }, - expectErr: "is not sorted", - }, - } - - for _, tc := range testCases { - s.Run(tc.name, func() { - expected := s.globalfeeKeeper.GetParams(s.ctx) - err := s.globalfeeKeeper.SetParams(s.ctx, tc.input) - if tc.expectErr != "" { - s.Require().ErrorContains(err, tc.expectErr) - } else { - expected = tc.input - s.Require().NoError(err) - } - - p := s.globalfeeKeeper.GetParams(s.ctx) - s.Require().Equal(expected, p) - }) - } -} diff --git a/x/globalfee/keeper/msg_server.go b/x/globalfee/keeper/msg_server.go deleted file mode 100644 index daa4b456c..000000000 --- a/x/globalfee/keeper/msg_server.go +++ /dev/null @@ -1,43 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -type msgServer struct { - Keeper -} - -var _ types.MsgServer = msgServer{} - -// NewMsgServerImpl returns an implementation of the MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} -} - -// UpdateParams updates the params. -func (ms msgServer) UpdateParams( - goCtx context.Context, - req *types.MsgUpdateParams, -) (*types.MsgUpdateParamsResponse, error) { - if ms.authority != req.Authority { - return nil, govtypes.ErrInvalidSigner.Wrapf( - "invalid authority; expected %s, got %s", - ms.authority, - req.Authority, - ) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - if err := ms.SetParams(ctx, req.Params); err != nil { - return nil, err - } - - return &types.MsgUpdateParamsResponse{}, nil -} diff --git a/x/globalfee/keeper/msg_server_test.go b/x/globalfee/keeper/msg_server_test.go deleted file mode 100644 index 50ec34f2f..000000000 --- a/x/globalfee/keeper/msg_server_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package keeper_test - -import ( - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -func (s *IntegrationTestSuite) TestUpdateParams() { - testCases := []struct { - name string - request *types.MsgUpdateParams - expectErr string - }{ - { - name: "set invalid authority", - request: &types.MsgUpdateParams{ - Authority: "foo", - }, - expectErr: "invalid authority", - }, - { - name: "set full valid params", - request: &types.MsgUpdateParams{ - Authority: s.globalfeeKeeper.GetAuthority(), - Params: types.Params{ - MinimumGasPrices: sdk.NewDecCoins( - sdk.NewDecCoin("ALX", math.NewInt(1)), - sdk.NewDecCoinFromDec("BLX", math.LegacyNewDecWithPrec(1, 3)), - ), - }, - }, - expectErr: "", - }, - { - name: "set empty coin", - request: &types.MsgUpdateParams{ - Authority: s.globalfeeKeeper.GetAuthority(), - Params: types.Params{ - MinimumGasPrices: sdk.DecCoins(nil), - }, - }, - expectErr: "", - }, - { - name: "set invalid denom", - request: &types.MsgUpdateParams{ - Authority: s.globalfeeKeeper.GetAuthority(), - Params: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "1AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(1)), - }, - }, - }, - }, - expectErr: "invalid denom", - }, - { - name: "set negative value", - request: &types.MsgUpdateParams{ - Authority: s.globalfeeKeeper.GetAuthority(), - Params: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(-1)), - }, - }, - }, - }, - expectErr: "is not positive", - }, - { - name: "set duplicated denom", - request: &types.MsgUpdateParams{ - Authority: s.globalfeeKeeper.GetAuthority(), - Params: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(1)), - }, - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(2)), - }, - }, - }, - }, - expectErr: "duplicate denomination", - }, - { - name: "set unsorted denom", - request: &types.MsgUpdateParams{ - Authority: s.globalfeeKeeper.GetAuthority(), - Params: types.Params{ - MinimumGasPrices: []sdk.DecCoin{ - { - Denom: "BBBB", - Amount: math.LegacyNewDecFromInt(math.NewInt(1)), - }, - { - Denom: "AAAA", - Amount: math.LegacyNewDecFromInt(math.NewInt(2)), - }, - }, - }, - }, - expectErr: "is not sorted", - }, - } - - for _, testcase := range testCases { - tc := testcase - s.Run(tc.name, func() { - _, err := s.msgServer.UpdateParams(s.ctx, tc.request) - if tc.expectErr != "" { - s.Require().ErrorContains(err, tc.expectErr) - } else { - s.Require().NoError(err) - } - }) - } -} diff --git a/x/globalfee/module.go b/x/globalfee/module.go deleted file mode 100644 index 33dd6dadf..000000000 --- a/x/globalfee/module.go +++ /dev/null @@ -1,121 +0,0 @@ -package globalfee - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/bandprotocol/chain/v3/x/globalfee/client/cli" - "github.com/bandprotocol/chain/v3/x/globalfee/keeper" - "github.com/bandprotocol/chain/v3/x/globalfee/types" -) - -// ConsensusVersion defines the current x/globalfee module consensus version. -const ConsensusVersion = 1 - -var ( - _ module.AppModuleBasic = AppModuleBasic{} - // _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} - _ module.HasServices = AppModule{} - - _ module.AppModule = AppModule{} -) - -// AppModuleBasic defines the basic application module used by the globalfee module. -type AppModuleBasic struct{} - -func (AppModuleBasic) Name() string { - return types.ModuleName -} - -// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(cdc) -} - -// RegisterInterfaces registers the module's interface types -func (AppModuleBasic) RegisterInterfaces(r codectypes.InterfaceRegistry) { - types.RegisterInterfaces(r) -} - -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesisState()) -} - -// Validation check of the Genesis -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { - var data types.GenesisState - if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } - - return data.Validate() -} - -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - panic(err) - } -} - -func (AppModuleBasic) GetTxCmd() *cobra.Command { - return nil -} - -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() -} - -type AppModule struct { - AppModuleBasic - - keeper keeper.Keeper -} - -// NewAppModule constructor -func NewAppModule(keeper keeper.Keeper) *AppModule { - return &AppModule{ - AppModuleBasic: AppModuleBasic{}, - keeper: keeper, - } -} - -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - -// IsAppModule implements the appmodule.AppModule interface. -func (am AppModule) IsAppModule() {} - -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { - var genesisState types.GenesisState - cdc.MustUnmarshalJSON(data, &genesisState) - am.keeper.InitGenesis(ctx, &genesisState) -} - -func (am AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) json.RawMessage { - genState := am.keeper.ExportGenesis(ctx) - return marshaler.MustMarshalJSON(genState) -} - -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), keeper.Querier{Keeper: am.keeper}) -} - -// ConsensusVersion is a sequence number for state-breaking change of the -// module. It should be incremented on each consensus-breaking change -// introduced by the module. To avoid wrong/empty versions, the initial version -// should be set to 1. -func (am AppModule) ConsensusVersion() uint64 { - return ConsensusVersion -} diff --git a/x/globalfee/types/codec.go b/x/globalfee/types/codec.go deleted file mode 100644 index 4b7504d44..000000000 --- a/x/globalfee/types/codec.go +++ /dev/null @@ -1,25 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Params{}, "globalfee/Params", nil) - legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "globalfee/MsgUpdateParams") -} - -// RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgUpdateParams{}, - ) - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} diff --git a/x/globalfee/types/genesis.go b/x/globalfee/types/genesis.go deleted file mode 100644 index f52af7190..000000000 --- a/x/globalfee/types/genesis.go +++ /dev/null @@ -1,43 +0,0 @@ -package types - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - - "github.com/cosmos/cosmos-sdk/codec" -) - -// NewGenesisState - Create a new genesis state -func NewGenesisState(params Params) *GenesisState { - return &GenesisState{ - Params: params, - } -} - -// DefaultGenesisState - Return a default genesis state -func DefaultGenesisState() *GenesisState { - return NewGenesisState(DefaultParams()) -} - -// GetGenesisStateFromAppState returns x/globalfee GenesisState given raw application -// genesis state. -func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) *GenesisState { - var genesisState GenesisState - - if appState[ModuleName] != nil { - cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) - } - - return &genesisState -} - -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (g GenesisState) Validate() error { - if err := g.Params.Validate(); err != nil { - return errorsmod.Wrap(err, "globalfee params") - } - - return nil -} diff --git a/x/globalfee/types/genesis.pb.go b/x/globalfee/types/genesis.pb.go deleted file mode 100644 index b3b88f815..000000000 --- a/x/globalfee/types/genesis.pb.go +++ /dev/null @@ -1,522 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: band/globalfee/v1beta1/genesis.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// GenesisState - initial state of module -type GenesisState struct { - // Params of this module - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_c3b4cca9ed9ac312, []int{0} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// Params defines the set of module parameters. -type Params struct { - // Minimum stores the minimum gas price(s) for all TX on the chain. - // When multiple coins are defined then they are accepted alternatively. - // The list must be sorted by denoms asc. No duplicate denoms or zero amount - // values allowed. For more information see - // https://docs.cosmos.network/main/modules/auth#concepts - MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_c3b4cca9ed9ac312, []int{1} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoins { - if m != nil { - return m.MinimumGasPrices - } - return nil -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "band.globalfee.v1beta1.GenesisState") - proto.RegisterType((*Params)(nil), "band.globalfee.v1beta1.Params") -} - -func init() { - proto.RegisterFile("band/globalfee/v1beta1/genesis.proto", fileDescriptor_c3b4cca9ed9ac312) -} - -var fileDescriptor_c3b4cca9ed9ac312 = []byte{ - // 338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xb1, 0x4e, 0x02, 0x31, - 0x18, 0xc7, 0xaf, 0x31, 0x61, 0x38, 0x1c, 0xc8, 0xc5, 0x18, 0x24, 0xa4, 0x67, 0x2e, 0x0e, 0x24, - 0x6a, 0x1b, 0x60, 0x73, 0x44, 0x13, 0x16, 0x07, 0x82, 0x9b, 0x0b, 0xf6, 0x4a, 0x3d, 0x1a, 0xaf, - 0xf7, 0x5d, 0x68, 0x21, 0xf2, 0x16, 0x3e, 0x87, 0xcf, 0xe0, 0x2e, 0x23, 0xa3, 0x13, 0x1a, 0xd8, - 0x1c, 0x7d, 0x02, 0x73, 0xd7, 0x13, 0x48, 0x70, 0x6a, 0x93, 0xfe, 0xbe, 0xff, 0xef, 0xcb, 0xbf, - 0xee, 0x59, 0xc8, 0x92, 0x21, 0x8d, 0x62, 0x08, 0x59, 0xfc, 0x28, 0x04, 0x9d, 0x36, 0x43, 0x61, - 0x58, 0x93, 0x46, 0x22, 0x11, 0x5a, 0x6a, 0x92, 0x8e, 0xc1, 0x80, 0x77, 0x9c, 0x51, 0x64, 0x43, - 0x91, 0x82, 0xaa, 0x1d, 0x45, 0x10, 0x41, 0x8e, 0xd0, 0xec, 0x66, 0xe9, 0x1a, 0xe6, 0xa0, 0x15, - 0x68, 0x1a, 0x32, 0xbd, 0x0d, 0xe4, 0x20, 0x13, 0xfb, 0x1e, 0x3c, 0xb8, 0x87, 0x5d, 0x1b, 0x7f, - 0x67, 0x98, 0x11, 0x5e, 0xcf, 0x2d, 0xa5, 0x6c, 0xcc, 0x94, 0xae, 0xa2, 0x53, 0xd4, 0x28, 0xb7, - 0x30, 0xf9, 0x5f, 0x47, 0x7a, 0x39, 0xd5, 0xa9, 0xce, 0x97, 0xbe, 0xf3, 0xbd, 0xf4, 0x2b, 0x76, - 0xea, 0x02, 0x94, 0x34, 0x42, 0xa5, 0x66, 0xd6, 0x2f, 0x72, 0x82, 0x77, 0xe4, 0x96, 0x2c, 0xec, - 0xbd, 0x21, 0xd7, 0x53, 0x32, 0x91, 0x6a, 0xa2, 0x06, 0x11, 0xd3, 0x83, 0x74, 0x2c, 0xb9, 0xc8, - 0x4c, 0x07, 0x8d, 0x72, 0xab, 0x4e, 0xec, 0xaa, 0x24, 0x5b, 0x75, 0xa3, 0xb9, 0x11, 0xfc, 0x1a, - 0x64, 0xd2, 0x49, 0x0b, 0x4f, 0x7d, 0x7f, 0x7e, 0xeb, 0xfc, 0x59, 0xfa, 0x27, 0x33, 0xa6, 0xe2, - 0xab, 0x60, 0x9f, 0x0a, 0x5e, 0x3f, 0xfd, 0xf3, 0x48, 0x9a, 0xd1, 0x24, 0x24, 0x1c, 0x14, 0x2d, - 0x7a, 0xb1, 0xc7, 0xa5, 0x1e, 0x3e, 0x51, 0x33, 0x4b, 0x85, 0xfe, 0x13, 0xea, 0x7e, 0xa5, 0xc8, - 0xe8, 0x32, 0xdd, 0xcb, 0x13, 0x3a, 0xb7, 0xf3, 0x15, 0x46, 0x8b, 0x15, 0x46, 0x5f, 0x2b, 0x8c, - 0x5e, 0xd6, 0xd8, 0x59, 0xac, 0xb1, 0xf3, 0xb1, 0xc6, 0xce, 0x7d, 0x6b, 0x27, 0x38, 0xeb, 0x2b, - 0xef, 0x96, 0x43, 0x4c, 0xf9, 0x88, 0xc9, 0x84, 0x4e, 0xdb, 0xf4, 0x79, 0xe7, 0x5f, 0x73, 0x51, - 0x58, 0xca, 0xa1, 0xf6, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x42, 0xa4, 0x5e, 0xf6, 0x01, - 0x00, 0x00, -} - -func (m *GenesisState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.MinimumGasPrices) > 0 { - for iNdEx := len(m.MinimumGasPrices) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MinimumGasPrices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - return n -} - -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.MinimumGasPrices) > 0 { - for _, e := range m.MinimumGasPrices { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GenesisState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinimumGasPrices", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MinimumGasPrices = append(m.MinimumGasPrices, types.DecCoin{}) - if err := m.MinimumGasPrices[len(m.MinimumGasPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenesis(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/globalfee/types/keys.go b/x/globalfee/types/keys.go deleted file mode 100644 index b4cc14221..000000000 --- a/x/globalfee/types/keys.go +++ /dev/null @@ -1,17 +0,0 @@ -package types - -const ( - // ModuleName is the name of the this module - ModuleName = "globalfee" - - // QuerierRoute is the querier route for the globalfee module - QuerierRoute = ModuleName - - // StoreKey to be used when creating the KVStore. - StoreKey = ModuleName - - // RouterKey is the msg router key for the globalfee module - RouterKey = ModuleName -) - -var ParamsKeyPrefix = []byte{0x01} diff --git a/x/globalfee/types/msgs.go b/x/globalfee/types/msgs.go deleted file mode 100644 index 107505e0f..000000000 --- a/x/globalfee/types/msgs.go +++ /dev/null @@ -1,26 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - TypeMsgUpdateParams = "update_params" -) - -var _ sdk.Msg = &MsgUpdateParams{} - -// ValidateBasic does a sanity check on the provided data. -func (m *MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { - return errorsmod.Wrap(err, "invalid authority address") - } - - if err := m.Params.Validate(); err != nil { - return err - } - - return nil -} diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go deleted file mode 100644 index 8c82c477f..000000000 --- a/x/globalfee/types/params.go +++ /dev/null @@ -1,32 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewParams returns Params instance with the given values. -func NewParams(minimumGasPrices sdk.DecCoins) Params { - return Params{ - MinimumGasPrices: minimumGasPrices, - } -} - -// DefaultParams returns default parameters -func DefaultParams() Params { - return Params{MinimumGasPrices: sdk.DecCoins{}} -} - -// this requires the fee non-negative -func validateMinimumGasPrices(i interface{}) error { - v, ok := i.(sdk.DecCoins) - if !ok { - return sdkerrors.ErrInvalidType.Wrapf("type: %T, expected sdk.DecCoins", i) - } - - return v.Validate() -} - -func (p Params) Validate() error { - return validateMinimumGasPrices(p.MinimumGasPrices) -} diff --git a/x/globalfee/types/params_test.go b/x/globalfee/types/params_test.go deleted file mode 100644 index 4e8e97788..000000000 --- a/x/globalfee/types/params_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package types - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func TestDefaultParams(t *testing.T) { - p := DefaultParams() - require.EqualValues(t, p.MinimumGasPrices, sdk.DecCoins{}) -} - -func TestValidateParams(t *testing.T) { - tests := map[string]struct { - coins interface{} // not sdk.DeCoins, but Decoins defined in glboalfee - expectErr bool - }{ - "DefaultParams, pass": { - DefaultParams().MinimumGasPrices, - false, - }, - "DecCoins conversion fails, fail": { - sdk.Coins{sdk.NewCoin("photon", math.OneInt())}, - true, - }, - "coins amounts are zero, fail": { - sdk.DecCoins{ - sdk.NewDecCoin("atom", math.ZeroInt()), - sdk.NewDecCoin("photon", math.ZeroInt()), - }, - true, - }, - "duplicate coins denoms, fail": { - sdk.DecCoins{ - sdk.NewDecCoin("photon", math.OneInt()), - sdk.NewDecCoin("photon", math.OneInt()), - }, - true, - }, - "coins are not sorted by denom alphabetically, fail": { - sdk.DecCoins{ - sdk.NewDecCoin("photon", math.OneInt()), - sdk.NewDecCoin("atom", math.OneInt()), - }, - true, - }, - } - - for name, test := range tests { - t.Run(name, func(t *testing.T) { - err := validateMinimumGasPrices(test.coins) - if test.expectErr { - require.Error(t, err) - return - } - require.NoError(t, err) - }) - } -} diff --git a/x/globalfee/types/query.pb.go b/x/globalfee/types/query.pb.go deleted file mode 100644 index 771a298f3..000000000 --- a/x/globalfee/types/query.pb.go +++ /dev/null @@ -1,538 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: band/globalfee/v1beta1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// QueryParamsRequest is request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f47ea1f06a5d914e, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // pagination defines an optional pagination for the request. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f47ea1f06a5d914e, []int{1} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "band.globalfee.v1beta1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "band.globalfee.v1beta1.QueryParamsResponse") -} - -func init() { - proto.RegisterFile("band/globalfee/v1beta1/query.proto", fileDescriptor_f47ea1f06a5d914e) -} - -var fileDescriptor_f47ea1f06a5d914e = []byte{ - // 295 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xbf, 0x4b, 0x03, 0x31, - 0x14, 0xc7, 0x2f, 0xa2, 0x1d, 0xe2, 0x16, 0x8b, 0x68, 0x95, 0xa8, 0x87, 0x83, 0x28, 0x24, 0xb4, - 0x5d, 0x9d, 0x3a, 0x3b, 0x68, 0xdd, 0xdc, 0x72, 0xe7, 0x33, 0x3d, 0xb8, 0xe6, 0x5d, 0x2f, 0xb9, - 0x62, 0x57, 0x71, 0x16, 0xc1, 0x7f, 0xaa, 0x63, 0xc1, 0xc5, 0x49, 0xe4, 0xce, 0x3f, 0x44, 0xee, - 0x07, 0xa2, 0xd8, 0x82, 0x5b, 0x78, 0xf9, 0xbc, 0xef, 0xfb, 0xf0, 0xa5, 0x7e, 0xa0, 0xcc, 0xad, - 0xd4, 0x31, 0x06, 0x2a, 0xbe, 0x03, 0x90, 0xd3, 0x6e, 0x00, 0x4e, 0x75, 0xe5, 0x24, 0x83, 0x74, - 0x26, 0x92, 0x14, 0x1d, 0xb2, 0xed, 0x92, 0x11, 0xdf, 0x8c, 0x68, 0x98, 0x4e, 0x5b, 0xa3, 0xc6, - 0x0a, 0x91, 0xe5, 0xab, 0xa6, 0x3b, 0xfb, 0x1a, 0x51, 0xc7, 0x20, 0x55, 0x12, 0x49, 0x65, 0x0c, - 0x3a, 0xe5, 0x22, 0x34, 0xb6, 0xf9, 0x3d, 0x5e, 0x71, 0x4f, 0x83, 0x01, 0x1b, 0x35, 0x94, 0xdf, - 0xa6, 0xec, 0xaa, 0x14, 0xb8, 0x54, 0xa9, 0x1a, 0xdb, 0x21, 0x4c, 0x32, 0xb0, 0xce, 0xbf, 0xa6, - 0x5b, 0xbf, 0xa6, 0x36, 0x41, 0x63, 0x81, 0x9d, 0xd3, 0x56, 0x52, 0x4d, 0x76, 0xc8, 0x21, 0x39, - 0xd9, 0xec, 0x71, 0xb1, 0xdc, 0x57, 0xd4, 0x7b, 0x83, 0xf5, 0xf9, 0xfb, 0x81, 0x37, 0x6c, 0x76, - 0x7a, 0x4f, 0x84, 0x6e, 0x54, 0xa9, 0xec, 0x91, 0xd0, 0x56, 0x8d, 0xb0, 0xd3, 0x55, 0x11, 0x7f, - 0xad, 0x3a, 0x67, 0xff, 0x62, 0x6b, 0x57, 0xff, 0xe8, 0xe1, 0xf5, 0xf3, 0x65, 0x6d, 0x8f, 0xed, - 0x2e, 0xa9, 0xa0, 0x16, 0x1a, 0x5c, 0xcc, 0x73, 0x4e, 0x16, 0x39, 0x27, 0x1f, 0x39, 0x27, 0xcf, - 0x05, 0xf7, 0x16, 0x05, 0xf7, 0xde, 0x0a, 0xee, 0xdd, 0xf4, 0x74, 0xe4, 0x46, 0x59, 0x20, 0x42, - 0x1c, 0xcb, 0xf2, 0x66, 0xd5, 0x55, 0x88, 0xb1, 0x0c, 0x47, 0x2a, 0x32, 0x72, 0xda, 0x97, 0xf7, - 0x3f, 0x62, 0xdd, 0x2c, 0x01, 0x1b, 0xb4, 0x2a, 0xa8, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa3, - 0xae, 0xd5, 0xe1, 0xe8, 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Params queries parameters of globalfee module - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/band.globalfee.v1beta1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Params queries parameters of globalfee module - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/band.globalfee.v1beta1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "band.globalfee.v1beta1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "band/globalfee/v1beta1/query.proto", -} - -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/globalfee/types/query.pb.gw.go b/x/globalfee/types/query.pb.gw.go deleted file mode 100644 index 8983f988d..000000000 --- a/x/globalfee/types/query.pb.gw.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: band/globalfee/v1beta1/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"globalfee", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage -) diff --git a/x/globalfee/types/tx.pb.go b/x/globalfee/types/tx.pb.go deleted file mode 100644 index 8ba7c2439..000000000 --- a/x/globalfee/types/tx.pb.go +++ /dev/null @@ -1,605 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: band/globalfee/v1beta1/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// MsgUpdateParams is the Msg/UpdateParams request type. -// -// Since: cosmos-sdk 0.47 -type MsgUpdateParams struct { - // authority is the address of the governance account. - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the x/globalfee parameters to update. - // - // NOTE: All parameters must be supplied. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_cd692734c3d1efd3, []int{0} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateParams) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// -// Since: cosmos-sdk 0.47 -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd692734c3d1efd3, []int{1} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgUpdateParams)(nil), "band.globalfee.v1beta1.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "band.globalfee.v1beta1.MsgUpdateParamsResponse") -} - -func init() { proto.RegisterFile("band/globalfee/v1beta1/tx.proto", fileDescriptor_cd692734c3d1efd3) } - -var fileDescriptor_cd692734c3d1efd3 = []byte{ - // 341 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0x4a, 0xcc, 0x4b, - 0xd1, 0x4f, 0xcf, 0xc9, 0x4f, 0x4a, 0xcc, 0x49, 0x4b, 0x4d, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, - 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x03, 0x29, 0xd0, - 0x83, 0x2b, 0xd0, 0x83, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd1, 0x07, 0xb1, - 0x20, 0xaa, 0xa5, 0x24, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xe3, 0x21, 0x12, 0x10, 0x0e, 0x54, - 0x4a, 0x1c, 0xc2, 0xd3, 0xcf, 0x2d, 0x4e, 0xd7, 0x2f, 0x33, 0x04, 0x51, 0x50, 0x09, 0x15, 0x1c, - 0x4e, 0x48, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x84, 0x6a, 0x57, 0x9a, 0xce, 0xc8, 0xc5, 0xef, 0x5b, - 0x9c, 0x1e, 0x5a, 0x90, 0x92, 0x58, 0x92, 0x1a, 0x90, 0x58, 0x94, 0x98, 0x5b, 0x2c, 0x64, 0xc6, - 0xc5, 0x99, 0x58, 0x5a, 0x92, 0x91, 0x5f, 0x94, 0x59, 0x52, 0x29, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, - 0xe9, 0x24, 0x71, 0x69, 0x8b, 0xae, 0x08, 0xd4, 0x5e, 0xc7, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0xe2, - 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x84, 0x52, 0x21, 0x1b, 0x2e, 0xb6, 0x02, 0xb0, 0x09, - 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x72, 0x7a, 0xd8, 0x3d, 0xa9, 0x07, 0xb1, 0xc7, 0x89, - 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x1e, 0x2b, 0xbe, 0xa6, 0xe7, 0x1b, 0xb4, 0x10, 0xa6, - 0x29, 0x49, 0x72, 0x89, 0xa3, 0x39, 0x2c, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0xa8, - 0x8c, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x83, 0x8b, 0x07, 0xc5, 0xdd, 0xea, 0xb8, 0xec, 0x43, - 0x33, 0x47, 0x4a, 0x9f, 0x48, 0x85, 0x30, 0x0b, 0xa5, 0x58, 0x1b, 0x9e, 0x6f, 0xd0, 0x62, 0x74, - 0xf2, 0x39, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, - 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xa3, 0xf4, 0xcc, 0x92, - 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x90, 0xd9, 0xe0, 0xc0, 0x4d, 0xce, 0xcf, 0xd1, - 0x4f, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x2f, 0x33, 0xd6, 0xaf, 0x40, 0x8a, 0x8a, 0x92, 0xca, 0x82, - 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x22, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x97, 0x88, - 0xe1, 0x2c, 0x02, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // UpdateParams defines a governance operation for updating the x/globalfee module - // parameters. - // - // Since: cosmos-sdk 0.47 - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/band.globalfee.v1beta1.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // UpdateParams defines a governance operation for updating the x/globalfee module - // parameters. - // - // Since: cosmos-sdk 0.47 - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/band.globalfee.v1beta1.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "band.globalfee.v1beta1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "band/globalfee/v1beta1/tx.proto", -} - -func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/oracle/app_test.go b/x/oracle/app_test.go index dca80867c..d794d438d 100644 --- a/x/oracle/app_test.go +++ b/x/oracle/app_test.go @@ -31,6 +31,7 @@ func TestAppTestSuite(t *testing.T) { func (s *AppTestSuite) SetupTest() { dir := testutil.GetTempDir(s.T()) + band.UseFeeMarketDecorator = false s.app = bandtesting.SetupWithCustomHome(false, dir) ctx := s.app.BaseApp.NewUncachedContext(false, cmtproto.Header{}) diff --git a/x/oracle/ibc_test.go b/x/oracle/ibc_test.go index 55d657ec5..c78c5c915 100644 --- a/x/oracle/ibc_test.go +++ b/x/oracle/ibc_test.go @@ -44,6 +44,7 @@ type IBCTestSuite struct { } func (suite *IBCTestSuite) SetupTest() { + band.UseFeeMarketDecorator = false ibctesting.DefaultTestingAppInit = bandtesting.CreateTestingAppFn(suite.T()) suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)