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

fix(evm): Simplify Gas Math #1452

Merged
merged 6 commits into from
Nov 18, 2022
Merged
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keeper

import (
"math"
"math/big"

sdkmath "cosmossdk.io/math"
Expand Down Expand Up @@ -241,8 +240,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
Expand Down