From 7aedcc91c98dd94d7a58f214bc73cc71ab9f10e5 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 12 Sep 2024 19:03:20 -0300 Subject: [PATCH] rebase fixes Signed-off-by: Ignacio Hagopian --- core/vm/evm.go | 11 +++++------ core/vm/instructions.go | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index f937d537d8c38..bdcd7d09619e7 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 3210941ec72e6..227d8f6525ef9 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