core: apply fixes for 8037

This commit is contained in:
Marius van der Wijden 2026-04-22 15:00:52 +02:00 committed by MariusVanDerWijden
parent c6c5536226
commit 2d708415d7

View file

@ -576,9 +576,8 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
st.state.Prepare(rules, msg.From, st.evm.Context.Coinbase, msg.To, vm.ActivePrecompiles(rules), msg.AccessList) st.state.Prepare(rules, msg.From, st.evm.Context.Coinbase, msg.To, vm.ActivePrecompiles(rules), msg.AccessList)
var ( var (
ret []byte ret []byte
vmerr error // vm errors do not effect consensus and are therefore not assigned to err vmerr error // vm errors do not effect consensus and are therefore not assigned to err
authRefund uint64
) )
var execGasUsed vm.GasUsed var execGasUsed vm.GasUsed
if contractCreation { if contractCreation {
@ -591,8 +590,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
if msg.SetCodeAuthorizations != nil { if msg.SetCodeAuthorizations != nil {
for _, auth := range msg.SetCodeAuthorizations { for _, auth := range msg.SetCodeAuthorizations {
// Note errors are ignored, we simply skip invalid authorizations here. // Note errors are ignored, we simply skip invalid authorizations here.
refund, _ := st.applyAuthorization(rules, &auth) st.applyAuthorization(rules, &auth)
authRefund += refund
} }
} }
@ -639,8 +637,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
// EIP-8037: 2D gas accounting for Amsterdam. // EIP-8037: 2D gas accounting for Amsterdam.
// tx_regular = intrinsic_regular + exec_regular_gas_used // tx_regular = intrinsic_regular + exec_regular_gas_used
// tx_state = intrinsic_state (adjusted) + exec_state_gas_used // tx_state = intrinsic_state (adjusted) + exec_state_gas_used
// These are tracked independently, not derived from remaining gas. txState := cost.StateGas + execGasUsed.StateGas
txState := (cost.StateGas - authRefund) + execGasUsed.StateGas
txRegular := cost.RegularGas + execGasUsed.RegularGas txRegular := cost.RegularGas + execGasUsed.RegularGas
txRegular = max(txRegular, floorDataGas) txRegular = max(txRegular, floorDataGas)
if err := st.gp.ReturnGasAmsterdam(txRegular, txState, st.gasUsed()); err != nil { if err := st.gp.ReturnGasAmsterdam(txRegular, txState, st.gasUsed()); err != nil {