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:
crypto-facs
2022-06-05 09:22:33 +00:00
committed by GitHub
co-authored by Federico Kunze Küllmer
parent 8155e1f319
commit 620f6a6770
46 changed files with 570 additions and 521 deletions
-18
View File
@@ -1,18 +0,0 @@
package v2
import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tharsis/ethermint/x/evm/types"
)
// AddMinGasMultiplierParam updates the module parameter MinGasMultiplier to 0.5
func AddMinGasMultiplierParam(ctx sdk.Context, paramStore *paramtypes.Subspace) error {
if !paramStore.HasKeyTable() {
ps := paramStore.WithKeyTable(types.ParamKeyTable())
paramStore = &ps
}
paramStore.Set(ctx, types.ParamStoreKeyMinGasMultiplier, types.DefaultMinGasMultiplier)
return nil
}
-46
View File
@@ -1,46 +0,0 @@
package v2_test
import (
"fmt"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/require"
"github.com/tharsis/ethermint/app"
"github.com/tharsis/ethermint/encoding"
v2 "github.com/tharsis/ethermint/x/evm/migrations/v2"
"github.com/tharsis/ethermint/x/evm/types"
"testing"
)
func TestAddMinGasMultiplierParam(t *testing.T) {
encCfg := encoding.MakeConfig(app.ModuleBasics)
erc20Key := sdk.NewKVStoreKey(types.StoreKey)
tErc20Key := sdk.NewTransientStoreKey(fmt.Sprintf("%s_test", types.StoreKey))
ctx := testutil.DefaultContext(erc20Key, tErc20Key)
paramStore := paramtypes.NewSubspace(
encCfg.Marshaler, encCfg.Amino, erc20Key, tErc20Key, "erc20",
)
paramStore = paramStore.WithKeyTable(types.ParamKeyTable())
require.True(t, paramStore.HasKeyTable())
// check no param
require.False(t, paramStore.Has(ctx, types.ParamStoreKeyMinGasMultiplier))
// Run migrations
err := v2.AddMinGasMultiplierParam(ctx, &paramStore)
require.NoError(t, err)
// Make sure the params are set
require.True(t, paramStore.Has(ctx, types.ParamStoreKeyMinGasMultiplier))
var minGasMultiplier sdk.Dec
// Make sure the new params are set
require.NotPanics(t, func() {
paramStore.Get(ctx, types.ParamStoreKeyMinGasMultiplier, &minGasMultiplier)
})
// check the params is up
require.Equal(t, minGasMultiplier, types.DefaultMinGasMultiplier)
}