EVM-C: include evm_result_outcome in evm_result

This commit is contained in:
Alex Beregszaszi 2016-08-23 22:58:39 +01:00
parent cead905a2e
commit abc914afd2
3 changed files with 19 additions and 3 deletions

View File

@ -80,8 +80,8 @@ int main(int argc, char *argv[]) {
sizeof(input), value);
printf("Execution result:\n");
if (result.gas_left & EVM_EXCEPTION) {
printf(" EVM eception\n");
if (result.outcome == EVM_RESULT_EXCEPTION) {
printf(" EVM exception\n");
}
printf(" Gas used: %ld\n", gas - result.gas_left);
printf(" Gas left: %ld\n", result.gas_left);

View File

@ -67,6 +67,7 @@ static struct evm_result evm_execute(struct evm_instance* instance,
// Execute code and refer to callbacks: instance->query_fn()
ret.outcome = EVM_RESULT_EXCEPTION;
ret.gas_left = 0;
return ret;

View File

@ -62,9 +62,24 @@ struct evm_hash256 {
#define EVM_EXCEPTION INT64_MIN ///< The execution ended with an exception.
/// The outcome of an execution.
enum evm_result_outcome {
EVM_RESULT_SUCCESS = 0,
EVM_RESULT_OUT_OF_GAS = 1,
EVM_RESULT_BAD_INSTRUCTION = 2,
EVM_RESULT_EXCEPTION = 3
};
/// Complex struct representing execution result.
struct evm_result {
/// Gas left after execution or exception indicator.
/// The outcome of the execution.
enum evm_result_outcome outcome;
/// Optional reason why the execution didn't succeed.
/// @see outcome.
const char *outcome_reason;
/// Gas left after execution.
int64_t gas_left;
/// Rerefence to output data. The memory containing the output data