EVMC
|
EVMC: Ethereum Client-VM Connector API. More...
Classes | |
struct | evmc_bytes32 |
The fixed size array of 32 bytes. More... | |
struct | evmc_address |
Big-endian 160-bit hash suitable for keeping an Ethereum address. More... | |
struct | evmc_message |
The message describing an EVM call, including a zero-depth calls from a transaction origin. More... | |
struct | evmc_tx_initcode |
The hashed initcode used for TXCREATE instruction. More... | |
struct | evmc_tx_context |
The transaction and block data for execution. More... | |
struct | evmc_result |
The EVM code execution result. More... | |
struct | evmc_host_interface |
The Host interface. More... | |
struct | evmc_vm |
The VM instance. More... | |
struct | evmc_host_context |
The opaque data type representing the Host execution context. More... | |
Typedefs | |
typedef struct evmc_bytes32 | evmc_bytes32 |
The fixed size array of 32 bytes. | |
typedef struct evmc_bytes32 | evmc_uint256be |
The alias for evmc_bytes32 to represent a big-endian 256-bit integer. | |
typedef struct evmc_address | evmc_address |
Big-endian 160-bit hash suitable for keeping an Ethereum address. | |
typedef struct evmc_tx_initcode | evmc_tx_initcode |
The hashed initcode used for TXCREATE instruction. | |
typedef struct evmc_tx_context(* | evmc_get_tx_context_fn) (struct evmc_host_context *context) |
Get transaction context callback function. | |
typedef evmc_bytes32(* | evmc_get_block_hash_fn) (struct evmc_host_context *context, int64_t number) |
Get block hash callback function. | |
typedef void(* | evmc_release_result_fn) (const struct evmc_result *result) |
Releases resources assigned to an execution result. | |
typedef bool(* | evmc_account_exists_fn) (struct evmc_host_context *context, const evmc_address *address) |
Check account existence callback function. | |
typedef evmc_bytes32(* | evmc_get_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key) |
Get storage callback function. | |
typedef evmc_bytes32(* | evmc_get_transient_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key) |
Get transient storage callback function. | |
typedef enum evmc_storage_status(* | evmc_set_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key, const evmc_bytes32 *value) |
Set storage callback function. | |
typedef void(* | evmc_set_transient_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key, const evmc_bytes32 *value) |
Set transient storage callback function. | |
typedef evmc_uint256be(* | evmc_get_balance_fn) (struct evmc_host_context *context, const evmc_address *address) |
Get balance callback function. | |
typedef size_t(* | evmc_get_code_size_fn) (struct evmc_host_context *context, const evmc_address *address) |
Get code size callback function. | |
typedef evmc_bytes32(* | evmc_get_code_hash_fn) (struct evmc_host_context *context, const evmc_address *address) |
Get code hash callback function. | |
typedef size_t(* | evmc_copy_code_fn) (struct evmc_host_context *context, const evmc_address *address, size_t code_offset, uint8_t *buffer_data, size_t buffer_size) |
Copy code callback function. | |
typedef bool(* | evmc_selfdestruct_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_address *beneficiary) |
Selfdestruct callback function. | |
typedef void(* | evmc_emit_log_fn) (struct evmc_host_context *context, const evmc_address *address, const uint8_t *data, size_t data_size, const evmc_bytes32 topics[], size_t topics_count) |
Log callback function. | |
typedef enum evmc_access_status(* | evmc_access_account_fn) (struct evmc_host_context *context, const evmc_address *address) |
Access account callback function. | |
typedef enum evmc_access_status(* | evmc_access_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key) |
Access storage callback function. | |
typedef struct evmc_result(* | evmc_call_fn) (struct evmc_host_context *context, const struct evmc_message *msg) |
Pointer to the callback function supporting EVM calls. | |
typedef void(* | evmc_destroy_fn) (struct evmc_vm *vm) |
Destroys the VM instance. | |
typedef enum evmc_set_option_result(* | evmc_set_option_fn) (struct evmc_vm *vm, char const *name, char const *value) |
Configures the VM instance. | |
typedef struct evmc_result(* | evmc_execute_fn) (struct evmc_vm *vm, const struct evmc_host_interface *host, struct evmc_host_context *context, enum evmc_revision rev, const struct evmc_message *msg, uint8_t const *code, size_t code_size) |
Executes the given code using the input from the message. | |
typedef uint32_t | evmc_capabilities_flagset |
Alias for unsigned integer representing a set of bit flags of EVMC capabilities. | |
typedef evmc_capabilities_flagset(* | evmc_get_capabilities_fn) (struct evmc_vm *vm) |
Return the supported capabilities of the VM instance. | |
Functions | |
struct evmc_vm * | evmc_create_example_vm (void) |
Example of a function creating an instance of an example EVM implementation. | |
EVMC: Ethereum Client-VM Connector API.
typedef enum evmc_access_status(* evmc_access_account_fn) (struct evmc_host_context *context, const evmc_address *address) |
Access account callback function.
This callback function is used by a VM to add the given address to accessed_addresses substate (EIP-2929).
context | The Host execution context. |
address | The address of the account. |
typedef enum evmc_access_status(* evmc_access_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key) |
Access storage callback function.
This callback function is used by a VM to add the given account storage entry to accessed_storage_keys substate (EIP-2929).
context | The Host execution context. |
address | The address of the account. |
key | The index of the account's storage entry. |
typedef bool(* evmc_account_exists_fn) (struct evmc_host_context *context, const evmc_address *address) |
Check account existence callback function.
This callback function is used by the VM to check if there exists an account at given address.
context | The pointer to the Host execution context. |
address | The address of the account the query is about. |
typedef struct evmc_bytes32 evmc_bytes32 |
The fixed size array of 32 bytes.
32 bytes of data capable of storing e.g. 256-bit hashes.
typedef struct evmc_result(* evmc_call_fn) (struct evmc_host_context *context, const struct evmc_message *msg) |
typedef uint32_t evmc_capabilities_flagset |
Alias for unsigned integer representing a set of bit flags of EVMC capabilities.
typedef size_t(* evmc_copy_code_fn) (struct evmc_host_context *context, const evmc_address *address, size_t code_offset, uint8_t *buffer_data, size_t buffer_size) |
Copy code callback function.
This callback function is used by an EVM to request a copy of the code of the given account to the memory buffer provided by the EVM. The Client MUST copy the requested code, starting with the given offset, to the provided memory buffer up to the size of the buffer or the size of the code, whichever is smaller.
context | The pointer to the Host execution context. See evmc_host_context. |
address | The address of the account. |
code_offset | The offset of the code to copy. |
buffer_data | The pointer to the memory buffer allocated by the EVM to store a copy of the requested code. |
buffer_size | The size of the memory buffer. |
typedef void(* evmc_destroy_fn) (struct evmc_vm *vm) |
typedef void(* evmc_emit_log_fn) (struct evmc_host_context *context, const evmc_address *address, const uint8_t *data, size_t data_size, const evmc_bytes32 topics[], size_t topics_count) |
Log callback function.
This callback function is used by an EVM to inform about a LOG that happened during an EVM bytecode execution.
context | The pointer to the Host execution context. See evmc_host_context. |
address | The address of the contract that generated the log. |
data | The pointer to unindexed data attached to the log. |
data_size | The length of the data. |
topics | The pointer to the array of topics attached to the log. |
topics_count | The number of the topics. Valid values are between 0 and 4 inclusively. |
typedef struct evmc_result(* evmc_execute_fn) (struct evmc_vm *vm, const struct evmc_host_interface *host, struct evmc_host_context *context, enum evmc_revision rev, const struct evmc_message *msg, uint8_t const *code, size_t code_size) |
Executes the given code using the input from the message.
This function MAY be invoked multiple times for a single VM instance.
vm | The VM instance. This argument MUST NOT be NULL. |
host | The Host interface. This argument MUST NOT be NULL unless the vm has the EVMC_CAPABILITY_PRECOMPILES capability. |
context | The opaque pointer to the Host execution context. This argument MAY be NULL. The VM MUST pass the same pointer to the methods of the host interface. The VM MUST NOT dereference the pointer. |
rev | The requested EVM specification revision. |
msg | The call parameters. See evmc_message. This argument MUST NOT be NULL. |
code | The reference to the code to be executed. This argument MAY be NULL. |
code_size | The length of the code. If code is NULL this argument MUST be 0. |
typedef evmc_uint256be(* evmc_get_balance_fn) (struct evmc_host_context *context, const evmc_address *address) |
Get balance callback function.
This callback function is used by a VM to query the balance of the given account.
context | The pointer to the Host execution context. |
address | The address of the account. |
typedef evmc_bytes32(* evmc_get_block_hash_fn) (struct evmc_host_context *context, int64_t number) |
Get block hash callback function.
This callback function is used by a VM to query the hash of the header of the given block. If the information about the requested block is not available, then this is signalled by returning null bytes.
context | The pointer to the Host execution context. |
number | The block number. |
typedef evmc_capabilities_flagset(* evmc_get_capabilities_fn) (struct evmc_vm *vm) |
Return the supported capabilities of the VM instance.
This function MAY be invoked multiple times for a single VM instance, and its value MAY be influenced by calls to evmc_vm::set_option.
vm | The VM instance. |
typedef evmc_bytes32(* evmc_get_code_hash_fn) (struct evmc_host_context *context, const evmc_address *address) |
Get code hash callback function.
This callback function is used by a VM to get the keccak256 hash of the code stored in the account at the given address. For existing accounts not having a code, this function returns keccak256 hash of empty data.
context | The pointer to the Host execution context. |
address | The address of the account. |
typedef size_t(* evmc_get_code_size_fn) (struct evmc_host_context *context, const evmc_address *address) |
Get code size callback function.
This callback function is used by a VM to get the size of the code stored in the account at the given address.
context | The pointer to the Host execution context. |
address | The address of the account. |
typedef evmc_bytes32(* evmc_get_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key) |
Get storage callback function.
This callback function is used by a VM to query the given account storage entry.
context | The Host execution context. |
address | The address of the account. |
key | The index of the account's storage entry. |
typedef evmc_bytes32(* evmc_get_transient_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key) |
Get transient storage callback function.
This callback function is used by a VM to query the given account transient storage (EIP-1153) entry.
context | The Host execution context. |
address | The address of the account. |
key | The index of the account's transient storage entry. |
typedef struct evmc_tx_context(* evmc_get_tx_context_fn) (struct evmc_host_context *context) |
typedef void(* evmc_release_result_fn) (const struct evmc_result *result) |
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 resources are to be released. The result itself it not modified by this function, but becomes invalid and user MUST discard it as well. This MUST NOT be NULL. |
typedef bool(* evmc_selfdestruct_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_address *beneficiary) |
Selfdestruct callback function.
This callback function is used by an EVM to SELFDESTRUCT given contract. The execution of the contract will not be stopped, that is up to the EVM.
context | The pointer to the Host execution context. See evmc_host_context. |
address | The address of the contract to be selfdestructed. |
beneficiary | The address where the remaining ETH is going to be transferred. |
typedef enum evmc_set_option_result(* evmc_set_option_fn) (struct evmc_vm *vm, char const *name, char const *value) |
Configures the VM instance.
Allows modifying options of the VM instance. Options:
vm | The VM 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 enum evmc_storage_status(* evmc_set_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key, const evmc_bytes32 *value) |
Set storage callback function.
This callback function is used by a VM to update the given account storage entry. The VM MUST make sure that the account exists. This requirement is only a formality because VM implementations only modify storage of the account of the current execution context (i.e. referenced by evmc_message::recipient).
context | The pointer to the Host execution context. |
address | The address of the account. |
key | The index of the storage entry. |
value | The value to be stored. |
typedef void(* evmc_set_transient_storage_fn) (struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key, const evmc_bytes32 *value) |
Set transient storage callback function.
This callback function is used by a VM to update the given account's transient storage (EIP-1153) entry. The VM MUST make sure that the account exists. This requirement is only a formality because VM implementations only modify storage of the account of the current execution context (i.e. referenced by evmc_message::recipient).
context | The pointer to the Host execution context. |
address | The address of the account. |
key | The index of the transient storage entry. |
value | The value to be stored. |
typedef struct evmc_bytes32 evmc_uint256be |
The alias for evmc_bytes32 to represent a big-endian 256-bit integer.
anonymous enum |
Enumerator | |
---|---|
EVMC_ABI_VERSION | The EVMC ABI version number of the interface declared in this file. The EVMC ABI version always equals the major version number of the EVMC project. The Host SHOULD check if the ABI versions match when dynamically loading VMs.
|
Definition at line 37 of file evmc.h.
enum evmc_access_status |
Access status per EIP-2929: Gas cost increases for state access opcodes.
Enumerator | |
---|---|
EVMC_ACCESS_COLD | The entry hasn't been accessed before – it's the first access. |
EVMC_ACCESS_WARM | The entry is already in accessed_addresses or accessed_storage_keys. |
Definition at line 783 of file evmc.h.
enum evmc_call_kind |
The kind of call-like instruction.
Definition at line 75 of file evmc.h.
enum evmc_capabilities |
Possible capabilities of a VM.
Enumerator | |
---|---|
EVMC_CAPABILITY_EVM1 | The VM is capable of executing EVM1 bytecode. |
EVMC_CAPABILITY_EWASM | The VM is capable of executing ewasm bytecode. |
EVMC_CAPABILITY_PRECOMPILES | The VM is capable of executing the precompiled contracts defined for the range of code addresses. The EIP-1352 (https://eips.ethereum.org/EIPS/eip-1352) specifies the range 0x000...0000 - 0x000...ffff of addresses reserved for precompiled and system contracts. This capability is experimental and MAY be removed without notice. |
Definition at line 1090 of file evmc.h.
enum evmc_flags |
The flags for evmc_message.
Enumerator | |
---|---|
EVMC_STATIC | Static call mode. |
enum evmc_revision |
EVM revision.
The revision of the EVM specification based on the Ethereum upgrade / hard fork codenames.
Enumerator | |
---|---|
EVMC_FRONTIER | The Frontier revision. The one Ethereum launched with. |
EVMC_HOMESTEAD | The Homestead revision. |
EVMC_TANGERINE_WHISTLE | The Tangerine Whistle revision. |
EVMC_SPURIOUS_DRAGON | The Spurious Dragon revision. |
EVMC_BYZANTIUM | The Byzantium revision. |
EVMC_CONSTANTINOPLE | The Constantinople revision. |
EVMC_PETERSBURG | The Petersburg revision. Other names: Constantinople2, ConstantinopleFix. |
EVMC_ISTANBUL | The Istanbul revision. |
EVMC_BERLIN | The Berlin revision. https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md |
EVMC_LONDON | The London revision. https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md |
EVMC_PARIS | The Paris revision (aka The Merge). https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md |
EVMC_SHANGHAI | The Shanghai revision. |
EVMC_CANCUN | The Cancun revision. https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md |
EVMC_PRAGUE | The Prague revision. The future next revision after Cancun. |
EVMC_OSAKA | The Osaka revision. The future next revision after Prague. |
EVMC_MAX_REVISION | The maximum EVM revision supported. |
EVMC_LATEST_STABLE_REVISION | The latest known EVM revision with finalized specification. This is handy for EVM tools to always use the latest revision available. |
Definition at line 940 of file evmc.h.
enum evmc_status_code |
The execution status code.
Successful execution is represented by EVMC_SUCCESS having value 0.
Positive values represent failures defined by VM specifications with generic EVMC_FAILURE code of value 1.
Status codes with negative values represent VM internal errors not provided by EVM specifications. These errors MUST not be passed back to the caller. They MAY be handled by the Client in predefined manner (see e.g. EVMC_REJECTED), otherwise internal errors are not recoverable. The generic representant of errors is EVMC_INTERNAL_ERROR but an EVM implementation MAY return negative status codes that are not defined in the EVMC documentation.
Enumerator | |
---|---|
EVMC_SUCCESS | Execution finished with success. |
EVMC_FAILURE | Generic execution failure. |
EVMC_REVERT | Execution terminated with REVERT opcode. In this case the amount of gas left MAY be non-zero and additional output data MAY be provided in evmc_result. |
EVMC_OUT_OF_GAS | The execution has run out of gas. |
EVMC_INVALID_INSTRUCTION | The designated INVALID instruction has been hit during execution. The EIP-141 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-141.md) defines the instruction 0xfe as INVALID instruction to indicate execution abortion coming from high-level languages. This status code is reported in case this INVALID instruction has been encountered. |
EVMC_UNDEFINED_INSTRUCTION | An undefined instruction has been encountered. |
EVMC_STACK_OVERFLOW | The execution has attempted to put more items on the EVM stack than the specified limit. |
EVMC_STACK_UNDERFLOW | Execution of an opcode has required more items on the EVM stack. |
EVMC_BAD_JUMP_DESTINATION | Execution has violated the jump destination restrictions. |
EVMC_INVALID_MEMORY_ACCESS | Tried to read outside memory bounds. An example is RETURNDATACOPY reading past the available buffer. |
EVMC_CALL_DEPTH_EXCEEDED | Call depth has exceeded the limit (if any) |
EVMC_STATIC_MODE_VIOLATION | Tried to execute an operation which is restricted in static mode. |
EVMC_PRECOMPILE_FAILURE | A call to a precompiled or system contract has ended with a failure. An example: elliptic curve functions handed invalid EC points. |
EVMC_CONTRACT_VALIDATION_FAILURE | Contract validation has failed (e.g. due to EVM 1.5 jump validity, Casper's purity checker or ewasm contract rules). |
EVMC_ARGUMENT_OUT_OF_RANGE | An argument to a state accessing method has a value outside of the accepted range of values. |
EVMC_WASM_UNREACHABLE_INSTRUCTION | A WebAssembly |
EVMC_WASM_TRAP | A WebAssembly trap has been hit during execution. This can be for many reasons, including division by zero, validation errors, etc. |
EVMC_INSUFFICIENT_BALANCE | The caller does not have enough funds for value transfer. |
EVMC_INTERNAL_ERROR | EVM implementation generic internal error. |
EVMC_REJECTED | The execution of the given code and/or message has been rejected by the EVM implementation. This error SHOULD be used to signal that the EVM is not able to or willing to execute the given code type or message. If an EVM returns the EVMC_REJECTED status code, the Client MAY try to execute it in other EVM implementation. For example, the Client tries running a code in the EVM 1.5. If the code is not supported there, the execution falls back to the EVM 1.0. |
EVMC_OUT_OF_MEMORY | The VM failed to allocate the amount of memory needed for execution. |
Definition at line 283 of file evmc.h.
enum evmc_storage_status |
The effect of an attempt to modify a contract storage item.
See EVM Storage Change Status for additional information about design of this enum and analysis of the specification.
For the purpose of explaining the meaning of each element, the following notation is used:
The order of elements follows EIPs introducing net storage gas costs:
Definition at line 568 of file evmc.h.
struct evmc_vm * evmc_create_example_vm | ( | void | ) |
Example of a function creating an instance of an example EVM implementation.
Each EVM implementation MUST provide a function returning an EVM instance. The function SHOULD be named evmc_create_<vm-name>(void)
. If the VM name contains hyphens replaces them with underscores in the function names.
libbeta-interpreter.so
.Definition at line 392 of file example_vm.cpp.