From a25d64a837771b29f3e6c56f40b1c229bf72ec29 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Fri, 3 Jul 2026 16:33:18 +0800 Subject: [PATCH] core/vm: polish --- core/vm/operations_acl.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/vm/operations_acl.go b/core/vm/operations_acl.go index 04ab5800bb..3669626d5a 100644 --- a/core/vm/operations_acl.go +++ b/core/vm/operations_acl.go @@ -400,7 +400,7 @@ func makeCallVariantGasCallEIP7702(intrinsicFunc intrinsicGasFunc, coldCost uint // Terminate the gas measurement if the leftover gas is not sufficient, // it can effectively prevent accessing the states in the following steps. // It's an essential safeguard before any stateful check. - if contract.Gas.RegularGas < intrinsicCost { + if !contract.chargeRegular(intrinsicCost, evm.Config.Tracer, tracing.GasChangeIgnored) { return GasCosts{}, ErrOutOfGas } @@ -415,9 +415,6 @@ func makeCallVariantGasCallEIP7702(intrinsicFunc intrinsicGasFunc, coldCost uint if !contract.chargeRegular(eip7702Cost, evm.Config.Tracer, tracing.GasChangeCallStorageColdAccess) { return GasCosts{}, ErrOutOfGas } - if contract.Gas.RegularGas < intrinsicCost { - return GasCosts{}, ErrOutOfGas - } // The delegated address has passed its gas check; record it in the // block access list now, before the call's sender-balance and // call-stack-depth checks. @@ -425,7 +422,7 @@ func makeCallVariantGasCallEIP7702(intrinsicFunc intrinsicGasFunc, coldCost uint } // Calculate the gas budget for the nested call. The costs defined by // EIP-2929 and EIP-7702 have already been applied. - evm.callGasTemp, err = callGas(evm.chainRules.IsEIP150, contract.Gas.RegularGas, intrinsicCost, stack.back(0)) + evm.callGasTemp, err = callGas(evm.chainRules.IsEIP150, contract.Gas.RegularGas, 0, stack.back(0)) if err != nil { return GasCosts{}, err } @@ -433,11 +430,13 @@ func makeCallVariantGasCallEIP7702(intrinsicFunc intrinsicGasFunc, coldCost uint // adding it to the return, it will be charged outside of this function, as // part of the dynamic gas. This will ensure it is correctly reported to // tracers. - contract.Gas.RegularGas += eip2929Cost + eip7702Cost + contract.Gas.RegularGas += eip2929Cost + eip7702Cost + intrinsicCost + // Undo the RegularGasUsed increments from the direct UseGas charges, // since this gas will be re-charged via the returned cost. contract.Gas.UsedRegularGas -= eip2929Cost contract.Gas.UsedRegularGas -= eip7702Cost + contract.Gas.UsedRegularGas -= intrinsicCost // Aggregate the gas costs from all components, including EIP-2929, EIP-7702, // the CALL opcode itself, and the cost incurred by nested calls.