EVMC
evmc.h
Go to the documentation of this file.
1 
11 #ifndef EVMC_H
12 #define EVMC_H
13 
14 #if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 6)
15 
21 #define EVMC_DEPRECATED __attribute__((deprecated))
22 #else
23 #define EVMC_DEPRECATED
24 #endif
25 
26 
27 #include <stdbool.h> /* Definition of bool, true and false. */
28 #include <stddef.h> /* Definition of size_t. */
29 #include <stdint.h> /* Definition of int64_t, uint64_t. */
30 
31 #if __cplusplus
32 extern "C" {
33 #endif
34 
35 /* BEGIN Python CFFI declarations */
36 
37 enum
38 {
48 };
49 
50 
56 typedef struct evmc_bytes32
57 {
59  uint8_t bytes[32];
60 } evmc_bytes32;
61 
66 
68 typedef struct evmc_address
69 {
71  uint8_t bytes[20];
72 } evmc_address;
73 
76 {
77  EVMC_CALL = 0,
83 };
84 
87 {
89 };
90 
96 {
98  enum evmc_call_kind kind;
99 
104  uint32_t flags;
105 
107  int32_t depth;
108 
110  int64_t gas;
111 
114 
117 
123  const uint8_t* input_data;
124 
130  size_t input_size;
131 
136 
143 };
144 
145 
148 {
152  int64_t block_number;
153  int64_t block_timestamp;
154  int64_t block_gas_limit;
157 };
158 
164 struct evmc_host_context;
165 
175 typedef struct evmc_tx_context (*evmc_get_tx_context_fn)(struct evmc_host_context* context);
176 
189 typedef evmc_bytes32 (*evmc_get_block_hash_fn)(struct evmc_host_context* context, int64_t number);
190 
212 {
215 
218 
226 
229 
239 
242 
248 
251 
254 
261 
264 
267 
274 
280 
286 
291 
297 
300 
313 
316 };
317 
318 /* Forward declaration. */
319 struct evmc_result;
320 
337 typedef void (*evmc_release_result_fn)(const struct evmc_result* result);
338 
341 {
343  enum evmc_status_code status_code;
344 
351  int64_t gas_left;
352 
364  const uint8_t* output_data;
365 
371  size_t output_size;
372 
393 
404 
416  uint8_t padding[4];
417 };
418 
419 
429 typedef bool (*evmc_account_exists_fn)(struct evmc_host_context* context,
430  const evmc_address* address);
431 
444  const evmc_address* address,
445  const evmc_bytes32* key);
446 
447 
460 {
465 
470 
475 
480 
485 };
486 
487 
503  const evmc_address* address,
504  const evmc_bytes32* key,
505  const evmc_bytes32* value);
506 
517  const evmc_address* address);
518 
529 typedef size_t (*evmc_get_code_size_fn)(struct evmc_host_context* context,
530  const evmc_address* address);
531 
544  const evmc_address* address);
545 
563 typedef size_t (*evmc_copy_code_fn)(struct evmc_host_context* context,
564  const evmc_address* address,
565  size_t code_offset,
566  uint8_t* buffer_data,
567  size_t buffer_size);
568 
579 typedef void (*evmc_selfdestruct_fn)(struct evmc_host_context* context,
580  const evmc_address* address,
581  const evmc_address* beneficiary);
582 
596 typedef void (*evmc_emit_log_fn)(struct evmc_host_context* context,
597  const evmc_address* address,
598  const uint8_t* data,
599  size_t data_size,
600  const evmc_bytes32 topics[],
601  size_t topics_count);
602 
610 typedef struct evmc_result (*evmc_call_fn)(struct evmc_host_context* context,
611  const struct evmc_message* msg);
612 
622 {
625 
628 
631 
634 
637 
640 
643 
646 
649 
652 
655 
658 };
659 
660 
661 /* Forward declaration. */
662 struct evmc_vm;
663 
669 typedef void (*evmc_destroy_fn)(struct evmc_vm* vm);
670 
675 {
676  EVMC_SET_OPTION_SUCCESS = 0,
677  EVMC_SET_OPTION_INVALID_NAME = 1,
678  EVMC_SET_OPTION_INVALID_VALUE = 2
679 };
680 
695  char const* name,
696  char const* value);
697 
698 
706 {
713 
720 
727 
734 
741 
748 
757 
764 
771 
774 };
775 
776 
795 typedef struct evmc_result (*evmc_execute_fn)(struct evmc_vm* vm,
796  const struct evmc_host_interface* host,
797  struct evmc_host_context* context,
798  enum evmc_revision rev,
799  const struct evmc_message* msg,
800  uint8_t const* code,
801  size_t code_size);
802 
807 {
811  EVMC_CAPABILITY_EVM1 = (1u << 0),
812 
817 
829 };
830 
836 typedef uint32_t evmc_capabilities_flagset;
837 
848 
849 
855 struct evmc_vm
856 {
863  const int abi_version;
864 
871  const char* name;
872 
879  const char* version;
880 
887 
894 
906 
913 };
914 
915 /* END Python CFFI declarations */
916 
917 #if EVMC_DOCUMENTATION
918 
933 struct evmc_vm* evmc_create_example_vm(void);
934 #endif
935 
936 #if __cplusplus
937 }
938 #endif
939 
940 #endif
941 
evmc_set_storage_fn set_storage
Set storage callback function.
Definition: evmc.h:630
evmc_bytes32(* evmc_get_code_hash_fn)(struct evmc_host_context *context, const evmc_address *address)
Get code hash callback function.
Definition: evmc.h:543
struct evmc_vm * evmc_create_example_vm(void)
Example of a function creating an instance of an example EVM implementation.
Definition: example_vm.c:219
The Tangerine Whistle revision.
Definition: evmc.h:726
void(* evmc_destroy_fn)(struct evmc_vm *vm)
Destroys the VM instance.
Definition: evmc.h:669
The Berlin revision.
Definition: evmc.h:770
A storage item has been deleted: X -> 0.
Definition: evmc.h:484
The Istanbul revision.
Definition: evmc.h:763
struct evmc_address evmc_address
Big-endian 160-bit hash suitable for keeping an Ethereum address.
evmc_flags
The flags for evmc_message.
Definition: evmc.h:86
evmc_bytes32(* evmc_get_storage_fn)(struct evmc_host_context *context, const evmc_address *address, const evmc_bytes32 *key)
Get storage callback function.
Definition: evmc.h:443
evmc_capabilities_flagset(* evmc_get_capabilities_fn)(struct evmc_vm *vm)
Return the supported capabilities of the VM instance.
Definition: evmc.h:847
evmc_selfdestruct_fn selfdestruct
Selfdestruct callback function.
Definition: evmc.h:645
evmc_status_code
The execution status code.
Definition: evmc.h:211
evmc_address destination
The destination of the message.
Definition: evmc.h:113
const char * name
The name of the EVMC VM implementation.
Definition: evmc.h:871
evmc_bytes32(* evmc_get_block_hash_fn)(struct evmc_host_context *context, int64_t number)
Get block hash callback function.
Definition: evmc.h:189
The VM failed to allocate the amount of memory needed for execution.
Definition: evmc.h:315
evmc_call_kind
The kind of call-like instruction.
Definition: evmc.h:75
Tried to execute an operation which is restricted in static mode.
Definition: evmc.h:266
void(* evmc_selfdestruct_fn)(struct evmc_host_context *context, const evmc_address *address, const evmc_address *beneficiary)
Selfdestruct callback function.
Definition: evmc.h:579
evmc_storage_status
The effect of an attempt to modify a contract storage item.
Definition: evmc.h:459
size_t(* evmc_get_code_size_fn)(struct evmc_host_context *context, const evmc_address *address)
Get code size callback function.
Definition: evmc.h:529
uint32_t flags
Additional flags modifying the call execution behavior.
Definition: evmc.h:104
bool(* evmc_account_exists_fn)(struct evmc_host_context *context, const evmc_address *address)
Check account existence callback function.
Definition: evmc.h:429
The execution has attempted to put more items on the EVM stack than the specified limit...
Definition: evmc.h:247
Execution of an opcode has required more items on the EVM stack.
Definition: evmc.h:250
Call depth has exceeded the limit (if any)
Definition: evmc.h:263
The VM is capable of executing ewasm bytecode.
Definition: evmc.h:816
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.
Definition: evmc.h:563
const int abi_version
EVMC ABI version implemented by the VM instance.
Definition: evmc.h:863
const char * version
The version of the EVMC VM implementation, e.g.
Definition: evmc.h:879
int64_t block_gas_limit
The block gas limit.
Definition: evmc.h:154
The Constantinople revision.
Definition: evmc.h:747
void(* evmc_release_result_fn)(const struct evmc_result *result)
Releases resources assigned to an execution result.
Definition: evmc.h:337
The execution of the given code and/or message has been rejected by the EVM implementation.
Definition: evmc.h:312
evmc_release_result_fn release
The method releasing all resources associated with the result object.
Definition: evmc.h:392
An argument to a state accessing method has a value outside of the accepted range of values...
Definition: evmc.h:285
struct evmc_tx_context(* evmc_get_tx_context_fn)(struct evmc_host_context *context)
Get transaction context callback function.
Definition: evmc.h:175
Request CREATE.
Definition: evmc.h:81
The Petersburg revision.
Definition: evmc.h:756
The VM is capable of executing EVM1 bytecode.
Definition: evmc.h:811
A WebAssembly unreachable instruction has been hit during execution.
Definition: evmc.h:290
evmc_address tx_origin
The transaction origin account.
Definition: evmc.h:150
A WebAssembly trap has been hit during execution.
Definition: evmc.h:296
evmc_uint256be tx_gas_price
The transaction gas price.
Definition: evmc.h:149
evmc_copy_code_fn copy_code
Copy code callback function.
Definition: evmc.h:642
The value of a storage item has been modified: X -> Y.
Definition: evmc.h:469
Tried to read outside memory bounds.
Definition: evmc.h:260
An undefined instruction has been encountered.
Definition: evmc.h:241
evmc_get_block_hash_fn get_block_hash
Get block hash callback function.
Definition: evmc.h:654
uint8_t bytes[32]
The 32 bytes.
Definition: evmc.h:59
The VM is capable of executing the precompiled contracts defined for the range of destination address...
Definition: evmc.h:828
size_t output_size
The size of the output data.
Definition: evmc.h:371
size_t input_size
The size of the message input data.
Definition: evmc.h:130
int64_t gas_left
The amount of gas left after the execution.
Definition: evmc.h:351
The Homestead revision.
Definition: evmc.h:719
The EVMC ABI version number of the interface declared in this file.
Definition: evmc.h:47
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.
Definition: evmc.h:502
EVM implementation generic internal error.
Definition: evmc.h:299
evmc_address create_address
The address of the contract created by create instructions.
Definition: evmc.h:403
The Host interface.
Definition: evmc.h:621
struct evmc_bytes32 evmc_bytes32
The fixed size array of 32 bytes.
evmc_get_code_size_fn get_code_size
Get code size callback function.
Definition: evmc.h:636
evmc_get_storage_fn get_storage
Get storage callback function.
Definition: evmc.h:627
The VM instance.
Definition: evmc.h:855
uint32_t evmc_capabilities_flagset
Alias for unsigned integer representing a set of bit flags of EVMC capabilities.
Definition: evmc.h:836
The opaque data type representing the Host execution context.
enum evmc_set_option_result(* evmc_set_option_fn)(struct evmc_vm *vm, char const *name, char const *value)
Configures the VM instance.
Definition: evmc.h:694
int32_t depth
The call depth.
Definition: evmc.h:107
The Frontier revision.
Definition: evmc.h:712
evmc_uint256be block_difficulty
The block difficulty.
Definition: evmc.h:155
The Spurious Dragon revision.
Definition: evmc.h:733
evmc_get_tx_context_fn get_tx_context
Get transaction context callback function.
Definition: evmc.h:651
evmc_uint256be(* evmc_get_balance_fn)(struct evmc_host_context *context, const evmc_address *address)
Get balance callback function.
Definition: evmc.h:516
The designated INVALID instruction has been hit during execution.
Definition: evmc.h:238
The message describing an EVM call, including a zero-depth calls from a transaction origin...
Definition: evmc.h:95
Execution terminated with REVERT opcode.
Definition: evmc.h:225
struct evmc_bytes32 evmc_uint256be
The alias for evmc_bytes32 to represent a big-endian 256-bit integer.
Definition: evmc.h:65
evmc_set_option_result
Possible outcomes of evmc_set_option.
Definition: evmc.h:674
evmc_set_option_fn set_option
Optional pointer to function modifying VM&#39;s options.
Definition: evmc.h:912
Big-endian 160-bit hash suitable for keeping an Ethereum address.
Definition: evmc.h:68
struct evmc_result(* evmc_call_fn)(struct evmc_host_context *context, const struct evmc_message *msg)
Pointer to the callback function supporting EVM calls.
Definition: evmc.h:610
Execution has violated the jump destination restrictions.
Definition: evmc.h:253
evmc_emit_log_fn emit_log
Emit log callback function.
Definition: evmc.h:657
int64_t block_number
The block number.
Definition: evmc.h:152
evmc_get_balance_fn get_balance
Get balance callback function.
Definition: evmc.h:633
Request CREATE2.
Definition: evmc.h:82
evmc_bytes32 create2_salt
The optional value used in new contract address construction.
Definition: evmc.h:142
evmc_call_fn call
Call callback function.
Definition: evmc.h:648
A call to a precompiled or system contract has ended with a failure.
Definition: evmc.h:273
evmc_uint256be chain_id
The blockchain&#39;s ChainID.
Definition: evmc.h:156
int64_t gas
The amount of gas for message execution.
Definition: evmc.h:110
A storage item has been modified after being modified before: X -> Y -> Z.
Definition: evmc.h:474
The EVM code execution result.
Definition: evmc.h:340
int64_t block_timestamp
The block timestamp.
Definition: evmc.h:153
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.
Definition: evmc.h:596
The maximum EVM revision supported.
Definition: evmc.h:773
The value of a storage item has been left unchanged: 0 -> 0 and X -> X.
Definition: evmc.h:464
evmc_destroy_fn destroy
Pointer to function destroying the VM instance.
Definition: evmc.h:886
Request CALLCODE.
Definition: evmc.h:80
Contract validation has failed (e.g.
Definition: evmc.h:279
Static call mode.
Definition: evmc.h:88
evmc_uint256be value
The amount of Ether transferred with the message.
Definition: evmc.h:135
evmc_account_exists_fn account_exists
Check account existence callback function.
Definition: evmc.h:624
The fixed size array of 32 bytes.
Definition: evmc.h:56
evmc_address sender
The sender of the message.
Definition: evmc.h:116
evmc_execute_fn execute
Pointer to function executing a code by the VM instance.
Definition: evmc.h:893
const uint8_t * output_data
The reference to output data.
Definition: evmc.h:364
The execution has run out of gas.
Definition: evmc.h:228
evmc_get_code_hash_fn get_code_hash
Get code hash callback function.
Definition: evmc.h:639
A new storage item has been added: 0 -> X.
Definition: evmc.h:479
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.
Definition: evmc.h:795
const uint8_t * input_data
The message input data.
Definition: evmc.h:123
evmc_address block_coinbase
The miner of the block.
Definition: evmc.h:151
evmc_revision
EVM revision.
Definition: evmc.h:705
Request CALL.
Definition: evmc.h:77
Request DELEGATECALL.
Definition: evmc.h:78
Generic execution failure.
Definition: evmc.h:217
evmc_get_capabilities_fn get_capabilities
A method returning capabilities supported by the VM instance.
Definition: evmc.h:905
The transaction and block data for execution.
Definition: evmc.h:147
Execution finished with success.
Definition: evmc.h:214
The Byzantium revision.
Definition: evmc.h:740
evmc_capabilities
Possible capabilities of a VM.
Definition: evmc.h:806