diff --git a/core/vm/evm.go b/core/vm/evm.go index f937d537d8c3..bdcd7d09619e 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -459,11 +459,10 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, // Charge the contract creation init gas in verkle mode if evm.chainRules.IsEIP4762 { gc := gasConsumer{availableGas: gas} - if !evm.Accesses.TouchAndChargeContractCreateCheck(address.Bytes(), gc.consumeGas){ - if statelessGas > gas { + if !evm.Accesses.TouchAndChargeContractCreateCheck(address.Bytes(), gc.consumeGas) { return nil, common.Address{}, 0, ErrOutOfGas } - gas = gas - statelessGas + gas = gc.availableGas } // We add this to the access list _before_ taking a snapshot. Even if the creation fails, // the access-list change should not be rolled back @@ -484,11 +483,11 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, // Charge the contract creation init gas in verkle mode if evm.chainRules.IsEIP4762 { - statelessGas := evm.Accesses.TouchAndChargeContractCreateInit(address.Bytes()) - if statelessGas > gas { + gc := gasConsumer{availableGas: gas} + if !evm.Accesses.TouchAndChargeContractCreateInit(address.Bytes(), gc.consumeGas) { return nil, common.Address{}, 0, ErrOutOfGas } - gas = gas - statelessGas + gas = gc.availableGas } evm.Context.Transfer(evm.StateDB, caller.Address(), address, value) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 3210941ec72e..227d8f6525ef 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -583,7 +583,7 @@ func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt } pos := scope.Stack.pop() if !scope.Contract.validJumpdest(&pos) { - if !scope.Contract.UseGas(interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false)) { + if !interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false, scope.Contract.UseGas) { return nil, ErrOutOfGas } return nil, ErrInvalidJump @@ -599,7 +599,7 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by pos, cond := scope.Stack.pop(), scope.Stack.pop() if !cond.IsZero() { if !scope.Contract.validJumpdest(&pos) { - if !scope.Contract.UseGas(interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false)) { + if !interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false, scope.Contract.UseGas) { return nil, ErrOutOfGas } return nil, ErrInvalidJump