Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

fix: default base fee state in genesis #919

Merged
merged 2 commits into from
Jan 26, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (app) [tharsis#873](https://github.com/tharsis/ethermint/pull/873) Validate code hash in GenesisAccount
* (evm) [tharsis#901](https://github.com/tharsis/ethermint/pull/901) Support multiple MsgEthereumTx in single tx.
* (config) [tharsis#908](https://github.com/tharsis/ethermint/pull/908) Add api.enable flag for Cosmos SDK Rest server
* (feemarket) [tharsis#919](https://github.com/tharsis/ethermint/pull/919) Initialize baseFee in default genesis state.

### Bug Fixes

Expand Down
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