forked from cerc-io/laconicd-deprecated
imp(feemarket): update BaseFee based on GasWanted (#1105)
* add gasWanted transient store keys * add gasWanted transient store keeper functions * add gasWanted transient store tracker * add comment * remove unncesary comment * remove unnecesary function * fix tests * fix bad comment * remove unnecesary comment * update comment * update changelog * Update CHANGELOG.md Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * add GasWantedDecorator * remove unnecesary comments * gasWanted decorator test * fix tests * fix tests and build * fix lint * updated end block event * Update app/ante/fee_market.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * fix undeclared variable * Update app/ante/fee_market_test.go * remove unnecesary line * migrate MinGasMultiplier to FeeMarket module * set limited gas wanted * remove old newKeeper param * update proto comment * fix test * update comments * Update x/feemarket/keeper/abci.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * address comments from review * tidy * tests Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze Küllmer
parent
8155e1f319
commit
620f6a6770
@@ -287,7 +287,7 @@ func (k *Keeper) GetBalance(ctx sdk.Context, addr common.Address) *big.Int {
|
||||
return coin.Amount.BigInt()
|
||||
}
|
||||
|
||||
// BaseFee returns current base fee, return values:
|
||||
// GetBaseFee returns current base fee, return values:
|
||||
// - `nil`: london hardfork not enabled.
|
||||
// - `0`: london hardfork enabled but feemarket is not enabled.
|
||||
// - `n`: both london hardfork and feemarket are enabled.
|
||||
@@ -303,6 +303,12 @@ func (k Keeper) GetBaseFee(ctx sdk.Context, ethCfg *params.ChainConfig) *big.Int
|
||||
return baseFee
|
||||
}
|
||||
|
||||
// GetMinGasMultiplier returns the MinGasMultiplier param from the fee market module
|
||||
func (k Keeper) GetMinGasMultiplier(ctx sdk.Context) sdk.Dec {
|
||||
fmkParmas := k.feeMarketKeeper.GetParams(ctx)
|
||||
return fmkParmas.MinGasMultiplier
|
||||
}
|
||||
|
||||
// ResetTransientGasUsed reset gas used to prepare for execution of current cosmos tx, called in ante handler.
|
||||
func (k Keeper) ResetTransientGasUsed(ctx sdk.Context) {
|
||||
store := ctx.TransientStore(k.transientKey)
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
v2 "github.com/tharsis/ethermint/x/evm/migrations/v2"
|
||||
)
|
||||
|
||||
// Migrator is a struct for handling in-place store migrations.
|
||||
type Migrator struct {
|
||||
keeper Keeper
|
||||
@@ -16,8 +11,3 @@ func NewMigrator(keeper Keeper) Migrator {
|
||||
keeper: keeper,
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate1to2 migrates the store from consensus version v1 to v2
|
||||
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
||||
return v2.AddMinGasMultiplierParam(ctx, &m.keeper.paramSpace)
|
||||
}
|
||||
|
||||
@@ -421,9 +421,9 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg core.Message, trace
|
||||
// calculate a minimum amount of gas to be charged to sender if GasLimit
|
||||
// is considerably higher than GasUsed to stay more aligned with Tendermint gas mechanics
|
||||
// for more info https://github.com/tharsis/ethermint/issues/1085
|
||||
// NOTE: MinGasDenominator can not be negative as it is validated on ValidateParams
|
||||
gasLimit := sdk.NewDec(int64(msg.Gas()))
|
||||
minimumGasUsed := gasLimit.Mul(cfg.Params.MinGasMultiplier)
|
||||
minGasMultiplier := k.GetMinGasMultiplier(ctx)
|
||||
minimumGasUsed := gasLimit.Mul(minGasMultiplier)
|
||||
gasUsed := sdk.MaxDec(minimumGasUsed, sdk.NewDec(int64(temporaryGasUsed))).TruncateInt().Uint64()
|
||||
|
||||
return &types.MsgEthereumTxResponse{
|
||||
|
||||
@@ -56,7 +56,7 @@ func (k Keeper) DeductTxCostsFromUserBalance(
|
||||
var feeAmt *big.Int
|
||||
|
||||
feeMktParams := k.feeMarketKeeper.GetParams(ctx)
|
||||
if london && !feeMktParams.NoBaseFee && txData.TxType() == ethtypes.DynamicFeeTxType {
|
||||
if london && feeMktParams.IsBaseFeeEnabled(ctx.BlockHeight()) && txData.TxType() == ethtypes.DynamicFeeTxType {
|
||||
baseFee := k.feeMarketKeeper.GetBaseFee(ctx)
|
||||
if txData.GetGasFeeCap().Cmp(baseFee) < 0 {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "the tx gasfeecap is lower than the tx baseFee: %s (gasfeecap), %s (basefee) ", txData.GetGasFeeCap(), baseFee)
|
||||
|
||||
Reference in New Issue
Block a user