From 207cac96be4eeea592f13617f95f3020afdb6960 Mon Sep 17 00:00:00 2001 From: Paul Lange Date: Tue, 7 Nov 2023 14:56:44 +0100 Subject: [PATCH] Fix gas refund --- core/state_transition.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 7add4b06c1..0b26dd427d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -649,9 +649,7 @@ func (st *StateTransition) refundGas(refundQuotient uint64) { } st.gasRemaining += refund - // Return ETH for remaining gas, exchanged at the original rate. - remaining := new(big.Int).Mul(new(big.Int).SetUint64(st.gasRemaining), st.msg.GasPrice) - st.state.AddBalance(st.msg.From, remaining) + // Gas refund now handled in `distributeTxFees` // Also return remaining gas to the block gas counter so it is // available for the next transaction. @@ -677,22 +675,13 @@ func (st *StateTransition) distributeTxFees() error { // defer func() { st.evm.SetDebug(true) }() // } msg := st.msg - // effectiveTip := msg.GasPrice - // if st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber) { - // effectiveTip = cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) - // } - if st.evm.Config.NoBaseFee && msg.GasFeeCap.Sign() == 0 && msg.GasTipCap.Sign() == 0 { // Skip fee payment when NoBaseFee is set and the fee fields // are 0. This avoids a negative effectiveTip being applied to // the coinbase when simulating calls. return nil } - // else { - // fee := new(big.Int).SetUint64(st.gasUsed()) - // fee.Mul(fee, effectiveTip) - // st.state.AddBalance(st.evm.Context.Coinbase, fee) - // } + // Determine the refund and transaction fee to be distributed. refund := new(big.Int).Mul(new(big.Int).SetUint64(st.gasRemaining), st.msg.GasPrice) gasUsed := new(big.Int).SetUint64(st.gasUsed())