diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 02e534f822..9c1b3e98d7 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -337,7 +337,14 @@ func (k *Keeper) ApplyMessageWithConfig( if vmCfg.Tracer != nil { if cfg.DebugTrace { // msg.GasPrice should have been set to effective gas price - stateDB.SubBalance(sender.Address(), new(big.Int).Mul(msg.GasPrice, new(big.Int).SetUint64(msg.GasLimit))) + var gasPrice *big.Int + if cfg.BaseFee == nil { + gasPrice = msg.GasPrice + } else { + // for legacy tx, the GasFeeCap/GasTipCap defaults to GasPrice, so it's compatible. + gasPrice = types.EffectiveGasPrice(cfg.BaseFee, msg.GasFeeCap, msg.GasTipCap) + } + stateDB.SubBalance(sender.Address(), new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(msg.GasLimit))) stateDB.SetNonce(sender.Address(), stateDB.GetNonce(sender.Address())+1) } vmCfg.Tracer.CaptureTxStart(leftoverGas)