EVM-C: Introduce evm_message

This commit is contained in:
Paweł Bylica 2017-01-12 16:45:14 +01:00 committed by Alex Beregszaszi
parent d6c5935cb4
commit a5625ee80a
3 changed files with 18 additions and 12 deletions

View File

@ -76,11 +76,13 @@ int main(int argc, char *argv[]) {
struct evm_uint256be code_hash = {.bytes = {1, 2, 3,}};
uint8_t const input[] = "Hello World!";
struct evm_uint256be value = {{1, 0, 0, 0}};
struct evm_uint160be addr = {{0, 1, 2,}};
int64_t gas = 200000;
struct evm_message msg = {addr, addr, value, input, sizeof(input), gas, 0};
struct evm_result result =
jit->execute(jit, NULL, EVM_HOMESTEAD, code_hash, code, code_size, gas,
input, sizeof(input), value);
jit->execute(jit, NULL, EVM_HOMESTEAD, code_hash, code, code_size, msg);
printf("Execution result:\n");
if (result.code != EVM_SUCCESS) {

View File

@ -43,10 +43,7 @@ static struct evm_result evm_execute(struct evm_instance* instance,
struct evm_uint256be code_hash,
uint8_t const* code,
size_t code_size,
int64_t gas,
uint8_t const* input,
size_t input_size,
struct evm_uint256be value)
struct evm_message message)
{
struct evm_result ret = {};
if (code_size == 0) {
@ -78,7 +75,7 @@ static struct evm_result evm_execute(struct evm_instance* instance,
ret.code = EVM_INTERNAL_ERROR;
return ret;
}
memcpy(output_data, &query_result.address, address_size);
memcpy(output_data, &message.address, address_size);
ret.code = EVM_SUCCESS;
ret.output_data = output_data;
ret.output_size = address_size;

View File

@ -46,6 +46,16 @@ struct evm_uint160be {
uint8_t bytes[20];
};
struct evm_message {
struct evm_uint160be address;
struct evm_uint160be sender;
struct evm_uint256be value;
const uint8_t* input;
size_t input_size;
int64_t gas;
int32_t depth;
};
/// The execution result code.
enum evm_result_code {
EVM_SUCCESS = 0, ///< Execution finished with success.
@ -420,10 +430,7 @@ typedef struct evm_result (*evm_execute_fn)(struct evm_instance* instance,
struct evm_uint256be code_hash,
uint8_t const* code,
size_t code_size,
int64_t gas,
uint8_t const* input,
size_t input_size,
struct evm_uint256be value);
struct evm_message message);
/// Status of a code in VM. Useful for JIT-like implementations.