From 2e01b63bbb7c83e182232b846b284e492f5eedb7 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:28:01 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Ignacio Hagopian --- core/vm/instructions.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 4305ee99dabc..1ecde85a1ff3 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -635,7 +635,9 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b if interpreter.evm.chainRules.IsEIP4762 { contractAddress := crypto.CreateAddress(scope.Contract.Address(), interpreter.evm.StateDB.GetNonce(scope.Contract.Address())) statelessGas := interpreter.evm.Accesses.TouchAndChargeContractCreateInit(contractAddress.Bytes()[:], value.Sign() != 0) - scope.Contract.UseGas(statelessGas) + if !scope.Contract.UseGas(statelessGas) { + return nil, ErrExecutionReverted + } } // reuse size int for stackvalue @@ -686,7 +688,9 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([] codeAndHash := &codeAndHash{code: input} contractAddress := crypto.CreateAddress2(scope.Contract.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes()) statelessGas := interpreter.evm.Accesses.TouchAndChargeContractCreateInit(contractAddress.Bytes()[:], endowment.Sign() != 0) - scope.Contract.UseGas(statelessGas) + if !scope.Contract.UseGas(statelessGas) { + return nil, ErrExecutionReverted + } } // Apply EIP150