Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update comments on globalfee, genutil module init order #2494

Merged
merged 4 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ func orderInitBlockers() []string {
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
// The globalfee module should ideally be initialized before the genutil module in theory:
yaruwangway marked this conversation as resolved.
Show resolved Hide resolved
// The globalfee antehandler performs checks in DeliverTx, which is called by gentx.
// When the global fee > 0, gentx needs to pay the fee. However, this is not expected,
// (in our case, the global fee is initialized with an empty value, which might not be a problem
// if the globalfee in genesis is not changed.)
// To resolve this issue, we should initialize the globalfee module after genutil, ensuring that the global
// min fee is empty when gentx is called.
// For more details, please refer to the following link: https://github.com/cosmos/gaia/issues/2489
globalfee.ModuleName,
providertypes.ModuleName,
}
Expand Down
20 changes: 10 additions & 10 deletions x/globalfee/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
var _ sdk.AnteDecorator = FeeDecorator{}

type FeeDecorator struct {
GlobalMinFee globalfee.ParamSource
yaruwangway marked this conversation as resolved.
Show resolved Hide resolved
StakingSubspace paramtypes.Subspace
GlobalMinFeeParamSource globalfee.ParamSource
StakingSubspace paramtypes.Subspace
}

func NewFeeDecorator(globalfeeSubspace, stakingSubspace paramtypes.Subspace) FeeDecorator {
Expand All @@ -42,8 +42,8 @@ func NewFeeDecorator(globalfeeSubspace, stakingSubspace paramtypes.Subspace) Fee
}

return FeeDecorator{
GlobalMinFee: globalfeeSubspace,
StakingSubspace: stakingSubspace,
GlobalMinFeeParamSource: globalfeeSubspace,
StakingSubspace: stakingSubspace,
}
}

Expand Down Expand Up @@ -186,8 +186,8 @@ func (mfd FeeDecorator) GetGlobalFee(ctx sdk.Context, feeTx sdk.FeeTx) (sdk.Coin
err error
)

if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyMinGasPrices) {
mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMinGasPrices, &globalMinGasPrices)
if mfd.GlobalMinFeeParamSource.Has(ctx, types.ParamStoreKeyMinGasPrices) {
mfd.GlobalMinFeeParamSource.Get(ctx, types.ParamStoreKeyMinGasPrices, &globalMinGasPrices)
}
// global fee is empty set, set global fee to 0uatom
if len(globalMinGasPrices) == 0 {
Expand Down Expand Up @@ -239,16 +239,16 @@ func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk
}

func (mfd FeeDecorator) GetBypassMsgTypes(ctx sdk.Context) (res []string) {
if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) {
mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &res)
if mfd.GlobalMinFeeParamSource.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) {
mfd.GlobalMinFeeParamSource.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &res)
}

return
}

func (mfd FeeDecorator) GetMaxTotalBypassMinFeeMsgGasUsage(ctx sdk.Context) (res uint64) {
if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) {
mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &res)
if mfd.GlobalMinFeeParamSource.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) {
mfd.GlobalMinFeeParamSource.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &res)
}

return
Expand Down
Loading