Merge remote-tracking branch 'marius/eip-7778' into HEAD

This commit is contained in:
Jared Wasinger 2026-01-27 14:18:51 -05:00
commit 6438bb43a2
2 changed files with 15 additions and 12 deletions

View file

@ -527,6 +527,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
peakGasUsed := st.gasUsed() peakGasUsed := st.gasUsed()
// Compute refund counter, capped to a refund quotient. // Compute refund counter, capped to a refund quotient.
gasBeforeRefunds := peakGasUsed
st.gasRemaining += st.calcRefund() st.gasRemaining += st.calcRefund()
if rules.IsPrague { if rules.IsPrague {
// After EIP-7623: Data-heavy transactions pay the floor gas. // After EIP-7623: Data-heavy transactions pay the floor gas.
@ -541,7 +542,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
peakGasUsed = floorDataGas peakGasUsed = floorDataGas
} }
} }
st.returnGas() st.returnGas(rules, gasBeforeRefunds)
effectiveTip := msg.GasPrice effectiveTip := msg.GasPrice
if rules.IsLondon { if rules.IsLondon {
@ -661,7 +662,7 @@ func (st *stateTransition) calcRefund() uint64 {
// returnGas returns ETH for remaining gas, // returnGas returns ETH for remaining gas,
// exchanged at the original rate. // exchanged at the original rate.
func (st *stateTransition) returnGas() { func (st *stateTransition) returnGas(rules params.Rules, gasBeforeRefunds uint64) {
remaining := uint256.NewInt(st.gasRemaining) remaining := uint256.NewInt(st.gasRemaining)
remaining.Mul(remaining, uint256.MustFromBig(st.msg.GasPrice)) remaining.Mul(remaining, uint256.MustFromBig(st.msg.GasPrice))
st.state.AddBalance(st.msg.From, remaining, tracing.BalanceIncreaseGasReturn) st.state.AddBalance(st.msg.From, remaining, tracing.BalanceIncreaseGasReturn)
@ -670,9 +671,14 @@ func (st *stateTransition) returnGas() {
st.evm.Config.Tracer.OnGasChange(st.gasRemaining, 0, tracing.GasChangeTxLeftOverReturned) st.evm.Config.Tracer.OnGasChange(st.gasRemaining, 0, tracing.GasChangeTxLeftOverReturned)
} }
// Also return remaining gas to the block gas counter so it is if !rules.IsAmsterdam {
// available for the next transaction. // Pre-Amsterdam return remaining gas to the block gas counter so it is
st.gp.AddGas(st.gasRemaining) // available for the next transaction.
st.gp.AddGas(st.gasRemaining)
} else {
// Post-Amsterdam only return the remaining gas minus the refunds.
st.gp.AddGas(gasBeforeRefunds)
}
} }
// gasUsed returns the amount of gas used up by the state transition. // gasUsed returns the amount of gas used up by the state transition.

View file

@ -397,13 +397,10 @@ const (
// execution (e.g. storage slot being cleared). this generates an increase in // execution (e.g. storage slot being cleared). this generates an increase in
// gas. There is at most one of such gas change per transaction. // gas. There is at most one of such gas change per transaction.
GasChangeTxRefunds GasChangeReason = 3 GasChangeTxRefunds GasChangeReason = 3
// GasChangeTxLeftOverReturned is the amount of gas left over at the end of transaction's execution that will be returned
// GasChangeTxLeftOverReturned is the amount of gas left over at the end of // to the account. This change will always be a negative change as we "drain" left over gas towards 0. If there was no gas
// transaction's execution that will be returned to the chain. This change // left at the end of execution, no such even will be emitted. The returned gas's value in Wei is returned to caller.
// will always be a negative change as we "drain" left over gas towards 0. // There is at most one of such gas change per transaction.
// If there was no gas left at the end of execution, no such even will be
// emitted. The returned gas's value in Wei is returned to caller. There is
// at most one of such gas change per transaction.
GasChangeTxLeftOverReturned GasChangeReason = 4 GasChangeTxLeftOverReturned GasChangeReason = 4
// GasChangeCallInitialBalance is the initial balance for the call which // GasChangeCallInitialBalance is the initial balance for the call which