Skip to content

Commit

Permalink
fix ConsensusParams
Browse files Browse the repository at this point in the history
fix evm
  • Loading branch information
mmsqe committed Jun 7, 2023
1 parent e41e077 commit b739244
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,15 @@ 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
evmSs := app.GetSubspace(evmtypes.ModuleName)
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
Expand Down
5 changes: 4 additions & 1 deletion x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,10 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type
hi = uint64(*args.Gas)
} else {
// Query block gas limit
params := ctx.ConsensusParams()
params, err := k.ck.Get(ctx)
if err != nil {
return nil, err
}
if params != nil && params.Block != nil && params.Block.MaxGas > 0 {
hi = uint64(params.Block.MaxGas)
} else {
Expand Down
4 changes: 4 additions & 0 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -78,6 +79,7 @@ type Keeper struct {
evmConstructor evm.Constructor
// Legacy subspace
ss paramstypes.Subspace
ck consensusparamkeeper.Keeper
}

// NewKeeper generates new evm module keeper
Expand All @@ -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 {
Expand All @@ -118,6 +121,7 @@ func NewKeeper(
evmConstructor: evmConstructor,
tracer: tracer,
ss: ss,
ck: ck,
}
}

Expand Down
6 changes: 4 additions & 2 deletions x/feemarket/keeper/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {
if !params.IsBaseFeeEnabled(ctx.BlockHeight()) {
return nil
}

consParams := ctx.ConsensusParams()
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
Expand Down
3 changes: 1 addition & 2 deletions x/feemarket/keeper/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion x/feemarket/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand All @@ -58,6 +60,7 @@ func NewKeeper(
authority: authority,
transientKey: transientKey,
ss: ss,
ck: ck,
}
}

Expand Down

0 comments on commit b739244

Please sign in to comment.