core/vm: wrap error

This commit is contained in:
Martin Holst Swende 2024-03-26 16:34:32 +01:00
parent 43ab2d2501
commit 1766c8ff18
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
4 changed files with 6 additions and 4 deletions

View file

@ -18,6 +18,7 @@ package vm
import (
"bytes"
"errors"
"math"
"math/big"
"sort"
@ -98,7 +99,7 @@ func TestEIP2200(t *testing.T) {
vmenv := NewEVM(vmctx, TxContext{}, statedb, params.AllEthashProtocolChanges, Config{ExtraEips: []int{2200}})
_, gas, err := vmenv.Call(AccountRef(common.Address{}), address, nil, tt.gaspool, new(uint256.Int))
if err != tt.failure {
if !errors.Is(err, tt.failure) {
t.Errorf("test %d: failure mismatch: have %v, want %v", i, err, tt.failure)
}
if used := tt.gaspool - gas; used != tt.used {

View file

@ -17,6 +17,7 @@
package vm
import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/tracing"
@ -256,7 +257,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
dynamicCost, err = operation.dynamicGas(in.evm, contract, stack, mem, memorySize)
cost += dynamicCost // for tracing
if err != nil {
return nil, err
return nil, fmt.Errorf("%w: %v", ErrOutOfGas, err)
}
if !contract.UseGas(dynamicCost, in.evm.Config.Tracer, tracing.GasChangeIgnored) {
return nil, ErrOutOfGas

View file

@ -57,7 +57,7 @@
"gas": "0x1a034",
"init": "0x36600060003760406103e8366000600060095af26001556103e8516002556104085160035500"
},
"error": "out of gas",
"error": "out of gas: not enough gas for reentrancy sentry",
"traceAddress": [],
"subtraces": 1,
"transactionPosition": 117,

View file

@ -57,7 +57,7 @@
"gas": "0x19ee4",
"init": "0x5a600055600060006000f0505a60015500"
},
"error": "out of gas",
"error": "out of gas: not enough gas for reentrancy sentry",
"traceAddress": [],
"subtraces": 1,
"transactionPosition": 63,