Skip to content

Commit

Permalink
fix defualt base fee state in genesis
Browse files Browse the repository at this point in the history
Closes: evmos#918
Solution:
- initialise the default base fee value in genesis
  • Loading branch information
yihuang committed Jan 25, 2022
1 parent fd3c803 commit b1c88f0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions x/evm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
suite.consAddress = sdk.ConsAddress(priv.PubKey().Address())

suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
feemarketGenesis := feemarkettypes.DefaultGenesisState()
if suite.enableFeemarket {
feemarketGenesis := feemarkettypes.DefaultGenesisState()
feemarketGenesis.Params.EnableHeight = 1
feemarketGenesis.Params.NoBaseFee = false
feemarketGenesis.BaseFee = sdk.NewInt(feemarketGenesis.Params.InitialBaseFee)
genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis)
} else {
feemarketGenesis.Params.NoBaseFee = true
feemarketGenesis.BaseFee = sdk.NewInt(0)
}
genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis)
if !suite.enableLondonHF {
evmGenesis := types.DefaultGenesisState()
maxInt := sdk.NewInt(math.MaxInt64)
Expand Down
2 changes: 1 addition & 1 deletion x/evm/keeper/state_transition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (suite *KeeperTestSuite) TestEVMConfig() {
suite.Require().NoError(err)
suite.Require().Equal(types.DefaultParams(), cfg.Params)
// london hardfork is enabled by default
suite.Require().Equal(new(big.Int), cfg.BaseFee)
suite.Require().Equal(big.NewInt(0), cfg.BaseFee)
suite.Require().Equal(suite.address, cfg.CoinBase)
suite.Require().Equal(types.DefaultParams().ChainConfig.EthereumConfig(big.NewInt(9000)), cfg.ChainConfig)
}
Expand Down
6 changes: 4 additions & 2 deletions x/feemarket/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper_test

import (
sdk "github.com/cosmos/cosmos-sdk/types"
ethparams "github.com/ethereum/go-ethereum/params"
"github.com/tharsis/ethermint/x/feemarket/types"
)

Expand Down Expand Up @@ -41,9 +42,10 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() {
expPass bool
}{
{
"pass - nil Base Fee",
"pass - default Base Fee",
func() {
expRes = &types.QueryBaseFeeResponse{}
initialBaseFee := sdk.NewInt(ethparams.InitialBaseFee)
expRes = &types.QueryBaseFeeResponse{BaseFee: &initialBaseFee}
},
true,
},
Expand Down
6 changes: 4 additions & 2 deletions x/feemarket/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/params"
)

// DefaultGenesisState sets default fee market genesis state.
func DefaultGenesisState() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
BaseFee: sdk.ZeroInt(),
Params: DefaultParams(),
// the default base fee should be initialized because the default enable height is zero.
BaseFee: sdk.NewIntFromUint64(params.InitialBaseFee),
BlockGas: 0,
}
}
Expand Down

0 comments on commit b1c88f0

Please sign in to comment.