diff --git a/CHANGELOG.md b/CHANGELOG.md index febcfcb4..5e31180f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (deps) [#1168](https://github.com/evmos/ethermint/pull/1168) Upgrade Cosmos SDK to `v0.46`. * (feemarket) [#1194](https://github.com/evmos/ethermint/pull/1194) Apply feemarket to native cosmos tx. * (eth) [#1346](https://github.com/evmos/ethermint/pull/1346) Added support for `sdk.Dec` and `ed25519` type on eip712. +* (evm) [#1452](https://github.com/evmos/ethermint/pull/1452) Simplify Gas Math in `ApplyTransaction`. * (eth) [#1430](https://github.com/evmos/ethermint/pull/1430) Added support for array of type `Any` on eip712.  * (ante) [1460](https://github.com/evmos/ethermint/pull/1460) Add KV Gas config on ethereum Txs. * (eth) [#1459](https://github.com/evmos/ethermint/pull/1459) Added support for messages with optional types omitted on eip712. diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 4dd9fe75..3103a45c 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -1,7 +1,6 @@ package keeper import ( - "math" "math/big" sdkmath "cosmossdk.io/math" @@ -242,8 +241,10 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t cumulativeGasUsed := res.GasUsed if ctx.BlockGasMeter() != nil { limit := ctx.BlockGasMeter().Limit() - consumed := ctx.BlockGasMeter().GasConsumed() - cumulativeGasUsed = uint64(math.Min(float64(cumulativeGasUsed+consumed), float64(limit))) + cumulativeGasUsed += ctx.BlockGasMeter().GasConsumed() + if cumulativeGasUsed > limit { + cumulativeGasUsed = limit + } } var contractAddr common.Address