core: polish

This commit is contained in:
Gary Rong 2026-07-13 09:24:17 +08:00
parent 60a9e39ba7
commit be1595f542

View file

@ -882,14 +882,14 @@ func (st *stateTransition) settleGas(rules params.Rules, floorDataGas uint64) (g
// EIP-8037: // EIP-8037:
// tx_gas_used_before_refund = tx.gas - tx_output.gas_left - tx_output.state_gas_reservoir // tx_gas_used_before_refund = tx.gas - tx_output.gas_left - tx_output.state_gas_reservoir
// tx_state_gas = intrinsic_state_gas + tx_output.execution_state_gas_used // tx_state_gas = intrinsic_state_gas + tx_output.execution_state_gas_used
// tx_regular_gas = tx_gas_used_before_refund - tx_state_gas // tx_regular_gas = max(tx_gas_used_before_refund - tx_state_gas, calldata_floor_gas_cost)
gasLeft := st.gasRemaining.RegularGas + st.gasRemaining.StateGas gasLeft := st.gasRemaining.RegularGas + st.gasRemaining.StateGas
gasUsedBeforeRefund := st.msg.GasLimit - gasLeft gasUsedBeforeRefund := st.msg.GasLimit - gasLeft
if gasUsedBeforeRefund < txStateGas { if gasUsedBeforeRefund < txStateGas {
return 0, 0, fmt.Errorf("negative topmost frame regular gas usage, total: %d, state: %d", gasUsedBeforeRefund, txStateGas) return 0, 0, fmt.Errorf("negative topmost frame regular gas usage, total: %d, state: %d", gasUsedBeforeRefund, txStateGas)
} }
txRegularGas := gasUsedBeforeRefund - txStateGas txRegularGas := max(gasUsedBeforeRefund-txStateGas, floorDataGas)
// EIP-3529: tx_gas_refund = min(tx_gas_used_before_refund/5, refund_counter). // EIP-3529: tx_gas_refund = min(tx_gas_used_before_refund/5, refund_counter).
refund := st.calcRefund(gasUsedBeforeRefund) refund := st.calcRefund(gasUsedBeforeRefund)
@ -912,7 +912,6 @@ func (st *stateTransition) settleGas(rules params.Rules, floorDataGas uint64) (g
} }
if rules.IsAmsterdam { if rules.IsAmsterdam {
txRegularGas = max(txRegularGas, floorDataGas)
if err = st.gp.ChargeGasAmsterdam(txRegularGas, txStateGas, gasUsed); err != nil { if err = st.gp.ChargeGasAmsterdam(txRegularGas, txStateGas, gasUsed); err != nil {
return 0, 0, err return 0, 0, err
} }