diff --git a/app/app.go b/app/app.go index a6ddfb39df..a2c8d83124 100644 --- a/app/app.go +++ b/app/app.go @@ -455,7 +455,7 @@ func NewEthermintApp( feeMarketSs := app.GetSubspace(feemarkettypes.ModuleName) app.FeeMarketKeeper = feemarketkeeper.NewKeeper( appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], feeMarketSs, + keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], feeMarketSs, app.ConsensusParamsKeeper, ) // Set authority to x/gov module account to only expect the module account to update params @@ -463,7 +463,7 @@ func NewEthermintApp( app.EvmKeeper = evmkeeper.NewKeeper( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, - nil, geth.NewEVM, tracer, evmSs, + nil, geth.NewEVM, tracer, evmSs, app.ConsensusParamsKeeper, ) // Create IBC Keeper diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 642300f41b..01c7ec4863 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -301,6 +301,11 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type } else { // Query block gas limit params := ctx.ConsensusParams() + if params == nil || params.Block == nil { + if params, err = k.ck.Get(ctx); err != nil { + return nil, err + } + } if params != nil && params.Block != nil && params.Block.MaxGas > 0 { hi = uint64(params.Block.MaxGas) } else { diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 58621e310a..4cd0d2bd8a 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" @@ -78,6 +79,7 @@ type Keeper struct { evmConstructor evm.Constructor // Legacy subspace ss paramstypes.Subspace + ck consensusparamkeeper.Keeper } // NewKeeper generates new evm module keeper @@ -93,6 +95,7 @@ func NewKeeper( evmConstructor evm.Constructor, tracer string, ss paramstypes.Subspace, + ck consensusparamkeeper.Keeper, ) *Keeper { // ensure evm module account is set if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { @@ -118,6 +121,7 @@ func NewKeeper( evmConstructor: evmConstructor, tracer: tracer, ss: ss, + ck: ck, } } diff --git a/x/feemarket/keeper/eip1559.go b/x/feemarket/keeper/eip1559.go index d477caa84e..7f566768bc 100644 --- a/x/feemarket/keeper/eip1559.go +++ b/x/feemarket/keeper/eip1559.go @@ -35,8 +35,14 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int { if !params.IsBaseFeeEnabled(ctx.BlockHeight()) { return nil } - consParams := ctx.ConsensusParams() + if consParams == nil || consParams.Block == nil { + var err error + consParams, err = k.ck.Get(ctx) + if err != nil { + return nil + } + } // If the current block is the first EIP-1559 block, return the base fee // defined in the parameters (DefaultBaseFee if it hasn't been changed by diff --git a/x/feemarket/keeper/eip1559_test.go b/x/feemarket/keeper/eip1559_test.go index 267e3cc9fe..4b02cac478 100644 --- a/x/feemarket/keeper/eip1559_test.go +++ b/x/feemarket/keeper/eip1559_test.go @@ -103,8 +103,7 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() { MaxBytes: 10, } consParams := tmproto.ConsensusParams{Block: &blockParams} - suite.ctx = suite.ctx.WithConsensusParams(&consParams) - + suite.app.ConsensusParamsKeeper.Set(suite.ctx, &consParams) fee := suite.app.FeeMarketKeeper.CalculateBaseFee(suite.ctx) if tc.NoBaseFee { suite.Require().Nil(fee, tc.name) diff --git a/x/feemarket/keeper/keeper.go b/x/feemarket/keeper/keeper.go index 5720f0ed51..2a23bd5926 100644 --- a/x/feemarket/keeper/keeper.go +++ b/x/feemarket/keeper/keeper.go @@ -24,6 +24,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" "github.com/evmos/ethermint/x/feemarket/types" ) @@ -41,11 +42,12 @@ type Keeper struct { authority sdk.AccAddress // Legacy subspace ss paramstypes.Subspace + ck consensusparamkeeper.Keeper } // NewKeeper generates new fee market module keeper func NewKeeper( - cdc codec.BinaryCodec, authority sdk.AccAddress, storeKey, transientKey storetypes.StoreKey, ss paramstypes.Subspace, + cdc codec.BinaryCodec, authority sdk.AccAddress, storeKey, transientKey storetypes.StoreKey, ss paramstypes.Subspace, ck consensusparamkeeper.Keeper, ) Keeper { // ensure authority account is correctly formatted if err := sdk.VerifyAddressFormat(authority); err != nil { @@ -58,6 +60,7 @@ func NewKeeper( authority: authority, transientKey: transientKey, ss: ss, + ck: ck, } }