Fabcoin Core
0.16.2
P2P Digital Currency
|
EVM-C – C interface to Ethereum Virtual Machine. More...
Classes | |
struct | evm_uint256be |
Big-endian 256-bit integer. More... | |
struct | evm_uint160be |
Big-endian 160-bit hash suitable for keeping an Ethereum address. More... | |
struct | evm_result |
The EVM code execution result. More... | |
union | evm_variant |
Variant type to represent possible types of values used in EVM. More... | |
struct | evm_instance |
The EVM instance. More... | |
struct | evm_factory |
The EVM instance factory. More... | |
Typedefs | |
typedef void(* | evm_release_result_fn) (struct evm_result const *result) |
Forward declaration. More... | |
typedef void(* | evm_query_fn) (union evm_variant *result, struct evm_env *env, enum evm_query_key key, const union evm_variant *arg) |
Query callback function. More... | |
typedef void(* | evm_update_fn) (struct evm_env *env, enum evm_update_key key, const union evm_variant *arg1, const union evm_variant *arg2) |
Update callback function. More... | |
typedef int64_t(* | evm_call_fn) (struct evm_env *env, enum evm_call_kind kind, int64_t gas, const struct evm_uint160be *address, const struct evm_uint256be *value, uint8_t const *input, size_t input_size, uint8_t *output, size_t output_size) |
Pointer to the callback function supporting EVM calls. More... | |
typedef struct evm_instance *(* | evm_create_fn) (evm_query_fn query_fn, evm_update_fn update_fn, evm_call_fn call_fn) |
Forward declaration. More... | |
typedef void(* | evm_destroy_fn) (struct evm_instance *evm) |
Destroys the EVM instance. More... | |
typedef int(* | evm_set_option_fn) (struct evm_instance *evm, char const *name, char const *value) |
Configures the EVM instance. More... | |
typedef struct evm_result(* | evm_execute_fn) (struct evm_instance *instance, struct evm_env *env, enum evm_mode mode, 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) |
Generates and executes machine code for given EVM bytecode. More... | |
typedef enum evm_code_status(* | evm_get_code_status_fn) (struct evm_instance *instance, enum evm_mode mode, struct evm_uint256be code_hash) |
Get information the status of the code in the VM. More... | |
typedef void(* | evm_prepare_code_fn) (struct evm_instance *instance, enum evm_mode mode, struct evm_uint256be code_hash, uint8_t const *code, size_t code_size) |
Request preparation of the code for faster execution. More... | |
Functions | |
struct evm_factory | examplevm_get_factory (void) |
Example of a function creating uninitialized instance of an example VM. More... | |
EVM-C – C interface to Ethereum Virtual Machine.
typedef int64_t(* evm_call_fn) (struct evm_env *env, enum evm_call_kind kind, int64_t gas, const struct evm_uint160be *address, const struct evm_uint256be *value, uint8_t const *input, size_t input_size, uint8_t *output, size_t output_size) |
Pointer to the callback function supporting EVM calls.
env | Pointer to execution environment managed by the host application. |
kind | The kind of call-like opcode requested. |
gas | The amount of gas for the call. |
address | The address of a contract to be called. Ignored in case of CREATE. |
value | The value sent to the callee. The endowment in case of CREATE. |
input | The call input data or the CREATE init code. |
input_size | The size of the input data. |
output | The reference to the memory where the call output is to be copied. In case of CREATE, the memory is guaranteed to be at least 20 bytes to hold the address of the created contract. |
output_data | The size of the output data. In case of CREATE, expected value is 20. |
typedef struct evm_instance*(* evm_create_fn) (evm_query_fn query_fn, evm_update_fn update_fn, evm_call_fn call_fn) |
Forward declaration.
Creates the EVM instance.
Creates and initializes an EVM instance by providing the information about runtime callback functions.
query_fn | Pointer to query callback function. Nonnull. |
update_fn | Pointer to update callback function. Nonnull. |
call_fn | Pointer to call callback function. Nonnull. |
typedef void(* evm_destroy_fn) (struct evm_instance *evm) |
typedef struct evm_result(* evm_execute_fn) (struct evm_instance *instance, struct evm_env *env, enum evm_mode mode, 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) |
Generates and executes machine code for given EVM bytecode.
All the fun is here. This function actually does something useful.
instance | A EVM instance. |
env | A pointer to the execution environment provided by the user and passed to callback functions. |
mode | EVM compatibility mode. |
code_hash | A hash of the bytecode, usually Keccak. The EVM uses it as the code identifier. A EVM implementation is able to hash the code itself if it requires it, but the host application usually has the hash already. |
code | Reference to the bytecode to be executed. |
code_size | The length of the bytecode. |
gas | Gas for execution. Min 0, max 2^63-1. |
input | Reference to the input data. |
input_size | The size of the input data. |
value | Call value. |
typedef enum evm_code_status(* evm_get_code_status_fn) (struct evm_instance *instance, enum evm_mode mode, struct evm_uint256be code_hash) |
typedef void(* evm_prepare_code_fn) (struct evm_instance *instance, enum evm_mode mode, struct evm_uint256be code_hash, uint8_t const *code, size_t code_size) |
typedef void(* evm_query_fn) (union evm_variant *result, struct evm_env *env, enum evm_query_key key, const union evm_variant *arg) |
Query callback function.
This callback function is used by the EVM to query the host application about additional data required to execute EVM code.
env | Pointer to execution environment managed by the host application. |
key | The kind of the query. See evm_query_key and details below. |
arg | Additional argument to the query. It has defined value only for the subset of query keys. |
arg | n/a |
arg | n/a |
arg | n/a |
arg | n/a |
arg | n/a |
arg | n/a |
arg | n/a |
arg | n/a |
arg | n/a |
arg | evm_variant::address The address to look up. |
arg | evm_variant::address The address to look up. |
arg | evm_variant::address The address to look up. |
arg | evm_variant::int64 The block number to look up. |
arg | evm_variant::uint256be The index of the storage entry. |
typedef void(* evm_release_result_fn) (struct evm_result const *result) |
Forward declaration.
Releases resources assigned to an execution result.
This function releases memory (and other resources, if any) assigned to the specified execution result making the result object invalid.
result | The execution result which resource are to be released. The result itself it not modified by this function, but becomes invalid and user should discard it as well. |
typedef int(* evm_set_option_fn) (struct evm_instance *evm, char const *name, char const *value) |
Configures the EVM instance.
Allows modifying options of the EVM instance. Options:
evm | The EVM instance to be configured. |
name | The option name. NULL-terminated string. Cannot be NULL. |
value | The new option value. NULL-terminated string. Cannot be NULL. |
typedef void(* evm_update_fn) (struct evm_env *env, enum evm_update_key key, const union evm_variant *arg1, const union evm_variant *arg2) |
Update callback function.
This callback function is used by the EVM to modify contract state in the host application.
env | Pointer to execution environment managed by the host application. |
key | The kind of the update. See evm_update_key and details below. |
arg1 | evm_variant::uint256be The index of the storage entry. |
arg2 | evm_variant::uint256be The value to be stored. |
arg1 | evm_variant::data The log unindexed data. |
arg2 | evm_variant::data The log topics. The referenced data is an array of evm_uint256be[] of possible length from 0 to 4. So the valid evm_variant::data_size values are 0, 32, 64 92 and 128. |
arg1 | evm_variant::address The beneficiary address. |
arg2 | n/a |
anonymous enum |
enum evm_call_kind |
enum evm_code_status |
enum evm_mode |
enum evm_query_key |
The query callback key.
enum evm_result_code |
enum evm_update_key |
struct evm_factory examplevm_get_factory | ( | void | ) |
Example of a function creating uninitialized instance of an example VM.
Each EVM implementation is obligated to provided a function returning an EVM instance. The function has to be named as <vm-name>_get_factory(void)
.
Definition at line 72 of file examplevm.c.