diff --git a/contracts/contract_call.go b/contracts/contract_call.go index 91aa466166..3e519c5764 100644 --- a/contracts/contract_call.go +++ b/contracts/contract_call.go @@ -107,15 +107,15 @@ func (bm *BoundMethod) run(vmRunner vm.EVMRunner, result interface{}, readOnly b if err != nil { message, _ := unpackError(output) - logger.Error("Error invoking evm function: EVM call failure", "input", hexutil.Encode(input), "maxgas", bm.maxGas, "err", err, "message", message) + logger.Error("Error invoking evm function: EVM call failure", "input", hexutil.Encode(input), "value", value, "maxgas", bm.maxGas, "err", err, "message", message) return err } if err := bm.decodeResult(result, output); err != nil { - logger.Error("Error invoking evm function: can't unpack result", "err", err, "maxgas", bm.maxGas) + logger.Error("Error invoking evm function: can't unpack result", "input", hexutil.Encode(input), "value", value, "err", err, "maxgas", bm.maxGas) return err } - logger.Trace("EVM call successful", "input", hexutil.Encode(input), "output", hexutil.Encode(output)) + logger.Trace("EVM call successful", "input", hexutil.Encode(input), "value", value, "output", hexutil.Encode(output)) return nil } diff --git a/core/vm/vmcontext/runner.go b/core/vm/vmcontext/runner.go index 331e620f48..c80d9bae44 100644 --- a/core/vm/vmcontext/runner.go +++ b/core/vm/vmcontext/runner.go @@ -1,6 +1,7 @@ package vmcontext import ( + "fmt" "math/big" "github.com/celo-org/celo-blockchain/common" @@ -20,16 +21,17 @@ type evmRunnerContext interface { } type evmRunner struct { - newEVM func(from common.Address) *vm.EVM - state vm.StateDB + newEVM func(from common.Address) *vm.EVM + state vm.StateDB + blockNum uint64 dontMeterGas bool } func NewEVMRunner(chain evmRunnerContext, header *types.Header, state vm.StateDB) vm.EVMRunner { - return &evmRunner{ - state: state, + blockNum: header.Number.Uint64(), + state: state, newEVM: func(from common.Address) *vm.EVM { // The EVM Context requires a msg, but the actual field values don't really matter for this case. // Putting in zero values for gas price and tx fee recipient @@ -49,6 +51,9 @@ func (ev *evmRunner) Execute(recipient common.Address, input []byte, gas uint64, evm.StopGasMetering() } ret, _, err = evm.Call(vm.AccountRef(evm.Origin), recipient, input, gas, value) + if err != nil { + err = fmt.Errorf("execute failed at block %d: %w", ev.blockNum, err) + } return ret, err } @@ -58,6 +63,9 @@ func (ev *evmRunner) ExecuteFrom(sender, recipient common.Address, input []byte, evm.StopGasMetering() } ret, _, err = evm.Call(vm.AccountRef(sender), recipient, input, gas, value) + if err != nil { + err = fmt.Errorf("execute from failed at block %d: %w", ev.blockNum, err) + } return ret, err } @@ -68,6 +76,9 @@ func (ev *evmRunner) ExecuteAndDiscardChanges(recipient common.Address, input [] evm.StopGasMetering() } ret, _, err = evm.Call(vm.AccountRef(evm.Origin), recipient, input, gas, value) + if err != nil { + err = fmt.Errorf("execute and discard changes failed at block %d: %w", ev.blockNum, err) + } evm.StateDB.RevertToSnapshot(snapshot) return ret, err } @@ -78,6 +89,9 @@ func (ev *evmRunner) Query(recipient common.Address, input []byte, gas uint64) ( evm.StopGasMetering() } ret, _, err = evm.StaticCall(vm.AccountRef(evm.Origin), recipient, input, gas) + if err != nil { + err = fmt.Errorf("query failed at block %d: %w", ev.blockNum, err) + } return ret, err }