diff --git a/core/state/access_witness.go b/core/state/access_witness.go index 24a1344e8e2b..276485e2dd25 100644 --- a/core/state/access_witness.go +++ b/core/state/access_witness.go @@ -284,7 +284,7 @@ func (aw *AccessWitness) TouchBasicData(addr []byte, isWrite bool, useGasFn UseG return ok && (!warmCostCharging || chargedGas > 0 || useGasFn(params.WarmStorageReadCostEIP2929)) } -func (aw *AccessWitness) TouchCodeHash(addr []byte, isWrite bool, useGasFn UseGasFn) bool { +func (aw *AccessWitness) TouchCodeHash(addr []byte, isWrite bool, useGasFn UseGasFn, warmCostCharging bool) bool { chargedGas, ok := aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeHashLeafKey, isWrite, useGasFn) - return ok && (chargedGas > 0 || useGasFn(params.WarmStorageReadCostEIP2929)) + return ok && (!warmCostCharging || chargedGas > 0 || useGasFn(params.WarmStorageReadCostEIP2929)) } diff --git a/core/vm/evm.go b/core/vm/evm.go index 2ab9479e66d1..f70f3552024a 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -206,9 +206,9 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas // is a direct tx call, in which case it's covered by the intrinsic gas, or because // of a CALL instruction, in which case BASIC_DATA has been added to the access // list in write mode. If there is enough gas paying for the addition of the code - // hash leaf to the access list, then account creation will proceed unimpaired. + // hash leaf to the access list, then account creation will proceed unimpaired. // Thus, only pay for the creation of the code hash leaf here. - ok := evm.Accesses.TouchCodeHash(addr.Bytes(), true, gc.consumeGas) + ok := evm.Accesses.TouchCodeHash(addr.Bytes(), true, gc.consumeGas, false) if !ok { evm.StateDB.RevertToSnapshot(snapshot) return nil, 0, ErrOutOfGas diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 912b9c583eeb..412093b1bb04 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -480,7 +480,7 @@ func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) return nil, ErrOutOfGas } } else { - if !interpreter.evm.Accesses.TouchCodeHash(address[:], false, scope.Contract.UseGas) { + if !interpreter.evm.Accesses.TouchCodeHash(address[:], false, scope.Contract.UseGas, true) { return nil, ErrOutOfGas } }