pub type __uint8_t = ::std::os::raw::c_uchar;
pub type __int32_t = ::std::os::raw::c_int;
pub type __uint32_t = ::std::os::raw::c_uint;
pub type __int64_t = ::std::os::raw::c_long;
pub const EVMC_ABI_VERSION: _bindgen_ty_1 = _bindgen_ty_1::EVMC_ABI_VERSION;
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_1 {
#[doc = " The EVMC ABI version number of the interface declared in this file."]
#[doc = ""]
#[doc = " The EVMC ABI version always equals the major version number of the EVMC project."]
#[doc = " The Host SHOULD check if the ABI versions match when dynamically loading VMs."]
#[doc = ""]
#[doc = " @see @ref versioning"]
EVMC_ABI_VERSION = 7,
}
#[doc = " The fixed size array of 32 bytes."]
#[doc = ""]
#[doc = " 32 bytes of data capable of storing e.g. 256-bit hashes."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_bytes32 {
#[doc = " The 32 bytes."]
pub bytes: [u8; 32usize],
}
#[test]
fn bindgen_test_layout_evmc_bytes32() {
assert_eq!(
::std::mem::size_of::<evmc_bytes32>(),
32usize,
concat!("Size of: ", stringify!(evmc_bytes32))
);
assert_eq!(
::std::mem::align_of::<evmc_bytes32>(),
1usize,
concat!("Alignment of ", stringify!(evmc_bytes32))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_bytes32>())).bytes as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(evmc_bytes32),
"::",
stringify!(bytes)
)
);
}
#[doc = " The alias for evmc_bytes32 to represent a big-endian 256-bit integer."]
pub type evmc_uint256be = evmc_bytes32;
#[doc = " Big-endian 160-bit hash suitable for keeping an Ethereum address."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_address {
#[doc = " The 20 bytes of the hash."]
pub bytes: [u8; 20usize],
}
#[test]
fn bindgen_test_layout_evmc_address() {
assert_eq!(
::std::mem::size_of::<evmc_address>(),
20usize,
concat!("Size of: ", stringify!(evmc_address))
);
assert_eq!(
::std::mem::align_of::<evmc_address>(),
1usize,
concat!("Alignment of ", stringify!(evmc_address))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_address>())).bytes as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(evmc_address),
"::",
stringify!(bytes)
)
);
}
#[repr(i32)]
#[doc = " The kind of call-like instruction."]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum evmc_call_kind {
#[doc = "< Request CALL."]
EVMC_CALL = 0,
#[doc = "< Request DELEGATECALL. Valid since Homestead."]
#[doc = "The value param ignored."]
EVMC_DELEGATECALL = 1,
#[doc = "< Request CALLCODE."]
EVMC_CALLCODE = 2,
#[doc = "< Request CREATE."]
EVMC_CREATE = 3,
#[doc = "< Request CREATE2. Valid since Constantinople."]
EVMC_CREATE2 = 4,
}
#[repr(i32)]
#[doc = " The flags for ::evmc_message."]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum evmc_flags {
#[doc = "< Static call mode."]
EVMC_STATIC = 1,
}
#[doc = " The message describing an EVM call,"]
#[doc = " including a zero-depth calls from a transaction origin."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_message {
#[doc = " The kind of the call. For zero-depth calls ::EVMC_CALL SHOULD be used."]
pub kind: evmc_call_kind,
#[doc = " Additional flags modifying the call execution behavior."]
#[doc = " In the current version the only valid values are ::EVMC_STATIC or 0."]
pub flags: u32,
#[doc = " The call depth."]
pub depth: i32,
#[doc = " The amount of gas for message execution."]
pub gas: i64,
#[doc = " The destination of the message."]
pub destination: evmc_address,
#[doc = " The sender of the message."]
pub sender: evmc_address,
#[doc = " The message input data."]
#[doc = ""]
#[doc = " This MAY be NULL."]
pub input_data: *const u8,
#[doc = " The size of the message input data."]
#[doc = ""]
#[doc = " If input_data is NULL this MUST be 0."]
pub input_size: usize,
#[doc = " The amount of Ether transferred with the message."]
pub value: evmc_uint256be,
#[doc = " The optional value used in new contract address construction."]
#[doc = ""]
#[doc = " Ignored unless kind is EVMC_CREATE2."]
pub create2_salt: evmc_bytes32,
}
#[test]
fn bindgen_test_layout_evmc_message() {
assert_eq!(
::std::mem::size_of::<evmc_message>(),
136usize,
concat!("Size of: ", stringify!(evmc_message))
);
assert_eq!(
::std::mem::align_of::<evmc_message>(),
8usize,
concat!("Alignment of ", stringify!(evmc_message))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).kind as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(kind)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).flags as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(flags)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).depth as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(depth)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).gas as *const _ as usize },
12usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(gas)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).destination as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(destination)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).sender as *const _ as usize },
36usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(sender)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).input_data as *const _ as usize },
56usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(input_data)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).input_size as *const _ as usize },
64usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(input_size)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).value as *const _ as usize },
72usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(value)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_message>())).create2_salt as *const _ as usize },
104usize,
concat!(
"Offset of field: ",
stringify!(evmc_message),
"::",
stringify!(create2_salt)
)
);
}
#[doc = " The transaction and block data for execution."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_tx_context {
#[doc = "< The transaction gas price."]
pub tx_gas_price: evmc_uint256be,
#[doc = "< The transaction origin account."]
pub tx_origin: evmc_address,
#[doc = "< The miner of the block."]
pub block_coinbase: evmc_address,
#[doc = "< The block number."]
pub block_number: i64,
#[doc = "< The block timestamp."]
pub block_timestamp: i64,
#[doc = "< The block gas limit."]
pub block_gas_limit: i64,
#[doc = "< The block difficulty."]
pub block_difficulty: evmc_uint256be,
#[doc = "< The blockchain's ChainID."]
pub chain_id: evmc_uint256be,
}
#[test]
fn bindgen_test_layout_evmc_tx_context() {
assert_eq!(
::std::mem::size_of::<evmc_tx_context>(),
148usize,
concat!("Size of: ", stringify!(evmc_tx_context))
);
assert_eq!(
::std::mem::align_of::<evmc_tx_context>(),
4usize,
concat!("Alignment of ", stringify!(evmc_tx_context))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_tx_context>())).tx_gas_price as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(tx_gas_price)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_tx_context>())).tx_origin as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(tx_origin)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_tx_context>())).block_coinbase as *const _ as usize },
52usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(block_coinbase)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_tx_context>())).block_number as *const _ as usize },
72usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(block_number)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_tx_context>())).block_timestamp as *const _ as usize },
76usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(block_timestamp)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_tx_context>())).block_gas_limit as *const _ as usize },
80usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(block_gas_limit)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<evmc_tx_context>())).block_difficulty as *const _ as usize
},
84usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(block_difficulty)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_tx_context>())).chain_id as *const _ as usize },
116usize,
concat!(
"Offset of field: ",
stringify!(evmc_tx_context),
"::",
stringify!(chain_id)
)
);
}
#[doc = " @struct evmc_host_context"]
#[doc = " The opaque data type representing the Host execution context."]
#[doc = " @see evmc_execute_fn()."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_host_context {
_unused: [u8; 0],
}
#[doc = " Get transaction context callback function."]
#[doc = ""]
#[doc = " This callback function is used by an EVM to retrieve the transaction and"]
#[doc = " block context."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @return The transaction context."]
pub type evmc_get_tx_context_fn =
::std::option::Option<unsafe extern "C" fn(context: *mut evmc_host_context) -> evmc_tx_context>;
#[doc = " Get block hash callback function."]
#[doc = ""]
#[doc = " This callback function is used by a VM to query the hash of the header of the given block."]
#[doc = " If the information about the requested block is not available, then this is signalled by"]
#[doc = " returning null bytes."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @param number The block number."]
#[doc = " @return The block hash or null bytes"]
#[doc = " if the information about the block is not available."]
pub type evmc_get_block_hash_fn = ::std::option::Option<
unsafe extern "C" fn(context: *mut evmc_host_context, number: i64) -> evmc_bytes32,
>;
#[repr(i32)]
#[doc = " The execution status code."]
#[doc = ""]
#[doc = " Successful execution is represented by ::EVMC_SUCCESS having value 0."]
#[doc = ""]
#[doc = " Positive values represent failures defined by VM specifications with generic"]
#[doc = " ::EVMC_FAILURE code of value 1."]
#[doc = ""]
#[doc = " Status codes with negative values represent VM internal errors"]
#[doc = " not provided by EVM specifications. These errors MUST not be passed back"]
#[doc = " to the caller. They MAY be handled by the Client in predefined manner"]
#[doc = " (see e.g. ::EVMC_REJECTED), otherwise internal errors are not recoverable."]
#[doc = " The generic representant of errors is ::EVMC_INTERNAL_ERROR but"]
#[doc = " an EVM implementation MAY return negative status codes that are not defined"]
#[doc = " in the EVMC documentation."]
#[doc = ""]
#[doc = " @note"]
#[doc = " In case new status codes are needed, please create an issue or pull request"]
#[doc = " in the EVMC repository (https://github.com/ethereum/evmc)."]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum evmc_status_code {
#[doc = " Execution finished with success."]
EVMC_SUCCESS = 0,
#[doc = " Generic execution failure."]
EVMC_FAILURE = 1,
#[doc = " Execution terminated with REVERT opcode."]
#[doc = ""]
#[doc = " In this case the amount of gas left MAY be non-zero and additional output"]
#[doc = " data MAY be provided in ::evmc_result."]
EVMC_REVERT = 2,
#[doc = " The execution has run out of gas."]
EVMC_OUT_OF_GAS = 3,
#[doc = " The designated INVALID instruction has been hit during execution."]
#[doc = ""]
#[doc = " The EIP-141 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-141.md)"]
#[doc = " defines the instruction 0xfe as INVALID instruction to indicate execution"]
#[doc = " abortion coming from high-level languages. This status code is reported"]
#[doc = " in case this INVALID instruction has been encountered."]
EVMC_INVALID_INSTRUCTION = 4,
#[doc = " An undefined instruction has been encountered."]
EVMC_UNDEFINED_INSTRUCTION = 5,
#[doc = " The execution has attempted to put more items on the EVM stack"]
#[doc = " than the specified limit."]
EVMC_STACK_OVERFLOW = 6,
#[doc = " Execution of an opcode has required more items on the EVM stack."]
EVMC_STACK_UNDERFLOW = 7,
#[doc = " Execution has violated the jump destination restrictions."]
EVMC_BAD_JUMP_DESTINATION = 8,
#[doc = " Tried to read outside memory bounds."]
#[doc = ""]
#[doc = " An example is RETURNDATACOPY reading past the available buffer."]
EVMC_INVALID_MEMORY_ACCESS = 9,
#[doc = " Call depth has exceeded the limit (if any)"]
EVMC_CALL_DEPTH_EXCEEDED = 10,
#[doc = " Tried to execute an operation which is restricted in static mode."]
EVMC_STATIC_MODE_VIOLATION = 11,
#[doc = " A call to a precompiled or system contract has ended with a failure."]
#[doc = ""]
#[doc = " An example: elliptic curve functions handed invalid EC points."]
EVMC_PRECOMPILE_FAILURE = 12,
#[doc = " Contract validation has failed (e.g. due to EVM 1.5 jump validity,"]
#[doc = " Casper's purity checker or ewasm contract rules)."]
EVMC_CONTRACT_VALIDATION_FAILURE = 13,
#[doc = " An argument to a state accessing method has a value outside of the"]
#[doc = " accepted range of values."]
EVMC_ARGUMENT_OUT_OF_RANGE = 14,
#[doc = " A WebAssembly `unreachable` instruction has been hit during execution."]
EVMC_WASM_UNREACHABLE_INSTRUCTION = 15,
#[doc = " A WebAssembly trap has been hit during execution. This can be for many"]
#[doc = " reasons, including division by zero, validation errors, etc."]
EVMC_WASM_TRAP = 16,
#[doc = " The caller does not have enough funds for value transfer."]
EVMC_INSUFFICIENT_BALANCE = 17,
#[doc = " EVM implementation generic internal error."]
EVMC_INTERNAL_ERROR = -1,
#[doc = " The execution of the given code and/or message has been rejected"]
#[doc = " by the EVM implementation."]
#[doc = ""]
#[doc = " This error SHOULD be used to signal that the EVM is not able to or"]
#[doc = " willing to execute the given code type or message."]
#[doc = " If an EVM returns the ::EVMC_REJECTED status code,"]
#[doc = " the Client MAY try to execute it in other EVM implementation."]
#[doc = " For example, the Client tries running a code in the EVM 1.5. If the"]
#[doc = " code is not supported there, the execution falls back to the EVM 1.0."]
EVMC_REJECTED = -2,
#[doc = " The VM failed to allocate the amount of memory needed for execution."]
EVMC_OUT_OF_MEMORY = -3,
}
#[doc = " Releases resources assigned to an execution result."]
#[doc = ""]
#[doc = " This function releases memory (and other resources, if any) assigned to the"]
#[doc = " specified execution result making the result object invalid."]
#[doc = ""]
#[doc = " @param result The execution result which resources are to be released. The"]
#[doc = " result itself it not modified by this function, but becomes"]
#[doc = " invalid and user MUST discard it as well."]
#[doc = " This MUST NOT be NULL."]
#[doc = ""]
#[doc = " @note"]
#[doc = " The result is passed by pointer to avoid (shallow) copy of the ::evmc_result"]
#[doc = " struct. Think of this as the best possible C language approximation to"]
#[doc = " passing objects by reference."]
pub type evmc_release_result_fn =
::std::option::Option<unsafe extern "C" fn(result: *const evmc_result)>;
#[doc = " The EVM code execution result."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_result {
#[doc = " The execution status code."]
pub status_code: evmc_status_code,
#[doc = " The amount of gas left after the execution."]
#[doc = ""]
#[doc = " If evmc_result::status_code is neither ::EVMC_SUCCESS nor ::EVMC_REVERT"]
#[doc = " the value MUST be 0."]
pub gas_left: i64,
#[doc = " The reference to output data."]
#[doc = ""]
#[doc = " The output contains data coming from RETURN opcode (iff evmc_result::code"]
#[doc = " field is ::EVMC_SUCCESS) or from REVERT opcode."]
#[doc = ""]
#[doc = " The memory containing the output data is owned by EVM and has to be"]
#[doc = " freed with evmc_result::release()."]
#[doc = ""]
#[doc = " This MAY be NULL."]
pub output_data: *const u8,
#[doc = " The size of the output data."]
#[doc = ""]
#[doc = " If output_data is NULL this MUST be 0."]
pub output_size: usize,
#[doc = " The method releasing all resources associated with the result object."]
#[doc = ""]
#[doc = " This method (function pointer) is optional (MAY be NULL) and MAY be set"]
#[doc = " by the VM implementation. If set it MUST be called by the user once to"]
#[doc = " release memory and other resources associated with the result object."]
#[doc = " Once the resources are released the result object MUST NOT be used again."]
#[doc = ""]
#[doc = " The suggested code pattern for releasing execution results:"]
#[doc = " @code"]
#[doc = " struct evmc_result result = ...;"]
#[doc = " if (result.release)"]
#[doc = " result.release(&result);"]
#[doc = " @endcode"]
#[doc = ""]
#[doc = " @note"]
#[doc = " It works similarly to C++ virtual destructor. Attaching the release"]
#[doc = " function to the result itself allows VM composition."]
pub release: evmc_release_result_fn,
#[doc = " The address of the contract created by create instructions."]
#[doc = ""]
#[doc = " This field has valid value only if:"]
#[doc = " - it is a result of the Host method evmc_host_interface::call"]
#[doc = " - and the result describes successful contract creation"]
#[doc = " (evmc_result::status_code is ::EVMC_SUCCESS)."]
#[doc = " In all other cases the address MUST be null bytes."]
pub create_address: evmc_address,
#[doc = " Reserved data that MAY be used by a evmc_result object creator."]
#[doc = ""]
#[doc = " This reserved 4 bytes together with 20 bytes from create_address form"]
#[doc = " 24 bytes of memory called \"optional data\" within evmc_result struct"]
#[doc = " to be optionally used by the evmc_result object creator."]
#[doc = ""]
#[doc = " @see evmc_result_optional_data, evmc_get_optional_data()."]
#[doc = ""]
#[doc = " Also extends the size of the evmc_result to 64 bytes (full cache line)."]
pub padding: [u8; 4usize],
}
#[test]
fn bindgen_test_layout_evmc_result() {
assert_eq!(
::std::mem::size_of::<evmc_result>(),
56usize,
concat!("Size of: ", stringify!(evmc_result))
);
assert_eq!(
::std::mem::align_of::<evmc_result>(),
8usize,
concat!("Alignment of ", stringify!(evmc_result))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_result>())).status_code as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(evmc_result),
"::",
stringify!(status_code)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_result>())).gas_left as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(evmc_result),
"::",
stringify!(gas_left)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_result>())).output_data as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(evmc_result),
"::",
stringify!(output_data)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_result>())).output_size as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(evmc_result),
"::",
stringify!(output_size)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_result>())).release as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(evmc_result),
"::",
stringify!(release)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_result>())).create_address as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(evmc_result),
"::",
stringify!(create_address)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_result>())).padding as *const _ as usize },
52usize,
concat!(
"Offset of field: ",
stringify!(evmc_result),
"::",
stringify!(padding)
)
);
}
#[doc = " Check account existence callback function."]
#[doc = ""]
#[doc = " This callback function is used by the VM to check if"]
#[doc = " there exists an account at given address."]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @param address The address of the account the query is about."]
#[doc = " @return true if exists, false otherwise."]
pub type evmc_account_exists_fn = ::std::option::Option<
unsafe extern "C" fn(context: *mut evmc_host_context, address: *const evmc_address) -> bool,
>;
#[doc = " Get storage callback function."]
#[doc = ""]
#[doc = " This callback function is used by a VM to query the given account storage entry."]
#[doc = ""]
#[doc = " @param context The Host execution context."]
#[doc = " @param address The address of the account."]
#[doc = " @param key The index of the account's storage entry."]
#[doc = " @return The storage value at the given storage key or null bytes"]
#[doc = " if the account does not exist."]
pub type evmc_get_storage_fn = ::std::option::Option<
unsafe extern "C" fn(
context: *mut evmc_host_context,
address: *const evmc_address,
key: *const evmc_bytes32,
) -> evmc_bytes32,
>;
#[repr(i32)]
#[doc = " The effect of an attempt to modify a contract storage item."]
#[doc = ""]
#[doc = " For the purpose of explaining the meaning of each element, the following"]
#[doc = " notation is used:"]
#[doc = " - 0 is zero value,"]
#[doc = " - X != 0 (X is any value other than 0),"]
#[doc = " - Y != X, Y != 0 (Y is any value other than X and 0),"]
#[doc = " - Z != Y (Z is any value other than Y),"]
#[doc = " - the \"->\" means the change from one value to another."]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum evmc_storage_status {
#[doc = " The value of a storage item has been left unchanged: 0 -> 0 and X -> X."]
EVMC_STORAGE_UNCHANGED = 0,
#[doc = " The value of a storage item has been modified: X -> Y."]
EVMC_STORAGE_MODIFIED = 1,
#[doc = " A storage item has been modified after being modified before: X -> Y -> Z."]
EVMC_STORAGE_MODIFIED_AGAIN = 2,
#[doc = " A new storage item has been added: 0 -> X."]
EVMC_STORAGE_ADDED = 3,
#[doc = " A storage item has been deleted: X -> 0."]
EVMC_STORAGE_DELETED = 4,
}
#[doc = " Set storage callback function."]
#[doc = ""]
#[doc = " This callback function is used by a VM to update the given account storage entry."]
#[doc = " The VM MUST make sure that the account exists. This requirement is only a formality because"]
#[doc = " VM implementations only modify storage of the account of the current execution context"]
#[doc = " (i.e. referenced by evmc_message::destination)."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @param address The address of the account."]
#[doc = " @param key The index of the storage entry."]
#[doc = " @param value The value to be stored."]
#[doc = " @return The effect on the storage item."]
pub type evmc_set_storage_fn = ::std::option::Option<
unsafe extern "C" fn(
context: *mut evmc_host_context,
address: *const evmc_address,
key: *const evmc_bytes32,
value: *const evmc_bytes32,
) -> evmc_storage_status,
>;
#[doc = " Get balance callback function."]
#[doc = ""]
#[doc = " This callback function is used by a VM to query the balance of the given account."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @param address The address of the account."]
#[doc = " @return The balance of the given account or 0 if the account does not exist."]
pub type evmc_get_balance_fn = ::std::option::Option<
unsafe extern "C" fn(
context: *mut evmc_host_context,
address: *const evmc_address,
) -> evmc_uint256be,
>;
#[doc = " Get code size callback function."]
#[doc = ""]
#[doc = " This callback function is used by a VM to get the size of the code stored"]
#[doc = " in the account at the given address."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @param address The address of the account."]
#[doc = " @return The size of the code in the account or 0 if the account does not exist."]
pub type evmc_get_code_size_fn = ::std::option::Option<
unsafe extern "C" fn(context: *mut evmc_host_context, address: *const evmc_address) -> usize,
>;
#[doc = " Get code hash callback function."]
#[doc = ""]
#[doc = " This callback function is used by a VM to get the keccak256 hash of the code stored"]
#[doc = " in the account at the given address. For existing accounts not having a code, this"]
#[doc = " function returns keccak256 hash of empty data."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @param address The address of the account."]
#[doc = " @return The hash of the code in the account or null bytes if the account does not exist."]
pub type evmc_get_code_hash_fn = ::std::option::Option<
unsafe extern "C" fn(
context: *mut evmc_host_context,
address: *const evmc_address,
) -> evmc_bytes32,
>;
#[doc = " Copy code callback function."]
#[doc = ""]
#[doc = " This callback function is used by an EVM to request a copy of the code"]
#[doc = " of the given account to the memory buffer provided by the EVM."]
#[doc = " The Client MUST copy the requested code, starting with the given offset,"]
#[doc = " to the provided memory buffer up to the size of the buffer or the size of"]
#[doc = " the code, whichever is smaller."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context. See ::evmc_host_context."]
#[doc = " @param address The address of the account."]
#[doc = " @param code_offset The offset of the code to copy."]
#[doc = " @param buffer_data The pointer to the memory buffer allocated by the EVM"]
#[doc = " to store a copy of the requested code."]
#[doc = " @param buffer_size The size of the memory buffer."]
#[doc = " @return The number of bytes copied to the buffer by the Client."]
pub type evmc_copy_code_fn = ::std::option::Option<
unsafe extern "C" fn(
context: *mut evmc_host_context,
address: *const evmc_address,
code_offset: usize,
buffer_data: *mut u8,
buffer_size: usize,
) -> usize,
>;
#[doc = " Selfdestruct callback function."]
#[doc = ""]
#[doc = " This callback function is used by an EVM to SELFDESTRUCT given contract."]
#[doc = " The execution of the contract will not be stopped, that is up to the EVM."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context. See ::evmc_host_context."]
#[doc = " @param address The address of the contract to be selfdestructed."]
#[doc = " @param beneficiary The address where the remaining ETH is going to be transferred."]
pub type evmc_selfdestruct_fn = ::std::option::Option<
unsafe extern "C" fn(
context: *mut evmc_host_context,
address: *const evmc_address,
beneficiary: *const evmc_address,
),
>;
#[doc = " Log callback function."]
#[doc = ""]
#[doc = " This callback function is used by an EVM to inform about a LOG that happened"]
#[doc = " during an EVM bytecode execution."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context. See ::evmc_host_context."]
#[doc = " @param address The address of the contract that generated the log."]
#[doc = " @param data The pointer to unindexed data attached to the log."]
#[doc = " @param data_size The length of the data."]
#[doc = " @param topics The pointer to the array of topics attached to the log."]
#[doc = " @param topics_count The number of the topics. Valid values are between 0 and 4 inclusively."]
pub type evmc_emit_log_fn = ::std::option::Option<
unsafe extern "C" fn(
context: *mut evmc_host_context,
address: *const evmc_address,
data: *const u8,
data_size: usize,
topics: *const evmc_bytes32,
topics_count: usize,
),
>;
#[doc = " Pointer to the callback function supporting EVM calls."]
#[doc = ""]
#[doc = " @param context The pointer to the Host execution context."]
#[doc = " @param msg The call parameters."]
#[doc = " @return The result of the call."]
pub type evmc_call_fn = ::std::option::Option<
unsafe extern "C" fn(context: *mut evmc_host_context, msg: *const evmc_message) -> evmc_result,
>;
#[doc = " The Host interface."]
#[doc = ""]
#[doc = " The set of all callback functions expected by VM instances. This is C"]
#[doc = " realisation of vtable for OOP interface (only virtual methods, no data)."]
#[doc = " Host implementations SHOULD create constant singletons of this (similarly"]
#[doc = " to vtables) to lower the maintenance and memory management cost."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_host_interface {
#[doc = " Check account existence callback function."]
pub account_exists: evmc_account_exists_fn,
#[doc = " Get storage callback function."]
pub get_storage: evmc_get_storage_fn,
#[doc = " Set storage callback function."]
pub set_storage: evmc_set_storage_fn,
#[doc = " Get balance callback function."]
pub get_balance: evmc_get_balance_fn,
#[doc = " Get code size callback function."]
pub get_code_size: evmc_get_code_size_fn,
#[doc = " Get code hash callback function."]
pub get_code_hash: evmc_get_code_hash_fn,
#[doc = " Copy code callback function."]
pub copy_code: evmc_copy_code_fn,
#[doc = " Selfdestruct callback function."]
pub selfdestruct: evmc_selfdestruct_fn,
#[doc = " Call callback function."]
pub call: evmc_call_fn,
#[doc = " Get transaction context callback function."]
pub get_tx_context: evmc_get_tx_context_fn,
#[doc = " Get block hash callback function."]
pub get_block_hash: evmc_get_block_hash_fn,
#[doc = " Emit log callback function."]
pub emit_log: evmc_emit_log_fn,
}
#[test]
fn bindgen_test_layout_evmc_host_interface() {
assert_eq!(
::std::mem::size_of::<evmc_host_interface>(),
96usize,
concat!("Size of: ", stringify!(evmc_host_interface))
);
assert_eq!(
::std::mem::align_of::<evmc_host_interface>(),
8usize,
concat!("Alignment of ", stringify!(evmc_host_interface))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<evmc_host_interface>())).account_exists as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(account_exists)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_host_interface>())).get_storage as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(get_storage)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_host_interface>())).set_storage as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(set_storage)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_host_interface>())).get_balance as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(get_balance)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<evmc_host_interface>())).get_code_size as *const _ as usize
},
32usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(get_code_size)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<evmc_host_interface>())).get_code_hash as *const _ as usize
},
40usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(get_code_hash)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_host_interface>())).copy_code as *const _ as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(copy_code)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<evmc_host_interface>())).selfdestruct as *const _ as usize
},
56usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(selfdestruct)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_host_interface>())).call as *const _ as usize },
64usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(call)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<evmc_host_interface>())).get_tx_context as *const _ as usize
},
72usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(get_tx_context)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<evmc_host_interface>())).get_block_hash as *const _ as usize
},
80usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(get_block_hash)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_host_interface>())).emit_log as *const _ as usize },
88usize,
concat!(
"Offset of field: ",
stringify!(evmc_host_interface),
"::",
stringify!(emit_log)
)
);
}
#[doc = " Destroys the VM instance."]
#[doc = ""]
#[doc = " @param vm The VM instance to be destroyed."]
pub type evmc_destroy_fn = ::std::option::Option<unsafe extern "C" fn(vm: *mut evmc_vm)>;
#[repr(i32)]
#[doc = " Possible outcomes of evmc_set_option."]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum evmc_set_option_result {
EVMC_SET_OPTION_SUCCESS = 0,
EVMC_SET_OPTION_INVALID_NAME = 1,
EVMC_SET_OPTION_INVALID_VALUE = 2,
}
#[doc = " Configures the VM instance."]
#[doc = ""]
#[doc = " Allows modifying options of the VM instance."]
#[doc = " Options:"]
#[doc = " - code cache behavior: on, off, read-only, ..."]
#[doc = " - optimizations,"]
#[doc = ""]
#[doc = " @param vm The VM instance to be configured."]
#[doc = " @param name The option name. NULL-terminated string. Cannot be NULL."]
#[doc = " @param value The new option value. NULL-terminated string. Cannot be NULL."]
#[doc = " @return The outcome of the operation."]
pub type evmc_set_option_fn = ::std::option::Option<
unsafe extern "C" fn(
vm: *mut evmc_vm,
name: *const ::std::os::raw::c_char,
value: *const ::std::os::raw::c_char,
) -> evmc_set_option_result,
>;
impl evmc_revision {
pub const EVMC_MAX_REVISION: evmc_revision = evmc_revision::EVMC_BERLIN;
}
#[repr(i32)]
#[doc = " EVM revision."]
#[doc = ""]
#[doc = " The revision of the EVM specification based on the Ethereum"]
#[doc = " upgrade / hard fork codenames."]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum evmc_revision {
#[doc = " The Frontier revision."]
#[doc = ""]
#[doc = " The one Ethereum launched with."]
EVMC_FRONTIER = 0,
#[doc = " The Homestead revision."]
#[doc = ""]
#[doc = " https://eips.ethereum.org/EIPS/eip-606"]
EVMC_HOMESTEAD = 1,
#[doc = " The Tangerine Whistle revision."]
#[doc = ""]
#[doc = " https://eips.ethereum.org/EIPS/eip-608"]
EVMC_TANGERINE_WHISTLE = 2,
#[doc = " The Spurious Dragon revision."]
#[doc = ""]
#[doc = " https://eips.ethereum.org/EIPS/eip-607"]
EVMC_SPURIOUS_DRAGON = 3,
#[doc = " The Byzantium revision."]
#[doc = ""]
#[doc = " https://eips.ethereum.org/EIPS/eip-609"]
EVMC_BYZANTIUM = 4,
#[doc = " The Constantinople revision."]
#[doc = ""]
#[doc = " https://eips.ethereum.org/EIPS/eip-1013"]
EVMC_CONSTANTINOPLE = 5,
#[doc = " The Petersburg revision."]
#[doc = ""]
#[doc = " Other names: Constantinople2, ConstantinopleFix."]
#[doc = ""]
#[doc = " https://eips.ethereum.org/EIPS/eip-1716"]
EVMC_PETERSBURG = 6,
#[doc = " The Istanbul revision."]
#[doc = ""]
#[doc = " The spec draft: https://eips.ethereum.org/EIPS/eip-1679."]
EVMC_ISTANBUL = 7,
#[doc = " The Berlin revision."]
#[doc = ""]
#[doc = " The spec draft: https://eips.ethereum.org/EIPS/eip-2070."]
EVMC_BERLIN = 8,
}
#[doc = " Executes the given code using the input from the message."]
#[doc = ""]
#[doc = " This function MAY be invoked multiple times for a single VM instance."]
#[doc = ""]
#[doc = " @param vm The VM instance. This argument MUST NOT be NULL."]
#[doc = " @param host The Host interface. This argument MUST NOT be NULL unless"]
#[doc = " the @p vm has the ::EVMC_CAPABILITY_PRECOMPILES capability."]
#[doc = " @param context The opaque pointer to the Host execution context."]
#[doc = " This argument MAY be NULL. The VM MUST pass the same"]
#[doc = " pointer to the methods of the @p host interface."]
#[doc = " The VM MUST NOT dereference the pointer."]
#[doc = " @param rev The requested EVM specification revision."]
#[doc = " @param msg The call parameters. See ::evmc_message. This argument MUST NOT be NULL."]
#[doc = " @param code The reference to the code to be executed. This argument MAY be NULL."]
#[doc = " @param code_size The length of the code. If @p code is NULL this argument MUST be 0."]
#[doc = " @return The execution result."]
pub type evmc_execute_fn = ::std::option::Option<
unsafe extern "C" fn(
vm: *mut evmc_vm,
host: *const evmc_host_interface,
context: *mut evmc_host_context,
rev: evmc_revision,
msg: *const evmc_message,
code: *const u8,
code_size: usize,
) -> evmc_result,
>;
#[repr(i32)]
#[doc = " Possible capabilities of a VM."]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum evmc_capabilities {
#[doc = " The VM is capable of executing EVM1 bytecode."]
EVMC_CAPABILITY_EVM1 = 1,
#[doc = " The VM is capable of executing ewasm bytecode."]
EVMC_CAPABILITY_EWASM = 2,
#[doc = " The VM is capable of executing the precompiled contracts"]
#[doc = " defined for the range of destination addresses."]
#[doc = ""]
#[doc = " The EIP-1352 (https://eips.ethereum.org/EIPS/eip-1352) specifies"]
#[doc = " the range 0x000...0000 - 0x000...ffff of addresses"]
#[doc = " reserved for precompiled and system contracts."]
#[doc = ""]
#[doc = " This capability is **experimental** and MAY be removed without notice."]
EVMC_CAPABILITY_PRECOMPILES = 4,
}
#[doc = " Alias for unsigned integer representing a set of bit flags of EVMC capabilities."]
#[doc = ""]
#[doc = " @see evmc_capabilities"]
pub type evmc_capabilities_flagset = u32;
#[doc = " Return the supported capabilities of the VM instance."]
#[doc = ""]
#[doc = " This function MAY be invoked multiple times for a single VM instance,"]
#[doc = " and its value MAY be influenced by calls to evmc_vm::set_option."]
#[doc = ""]
#[doc = " @param vm The VM instance."]
#[doc = " @return The supported capabilities of the VM. @see evmc_capabilities."]
pub type evmc_get_capabilities_fn =
::std::option::Option<unsafe extern "C" fn(vm: *mut evmc_vm) -> evmc_capabilities_flagset>;
#[doc = " The VM instance."]
#[doc = ""]
#[doc = " Defines the base struct of the VM implementation."]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
pub struct evmc_vm {
#[doc = " EVMC ABI version implemented by the VM instance."]
#[doc = ""]
#[doc = " Can be used to detect ABI incompatibilities."]
#[doc = " The EVMC ABI version represented by this file is in ::EVMC_ABI_VERSION."]
pub abi_version: ::std::os::raw::c_int,
#[doc = " The name of the EVMC VM implementation."]
#[doc = ""]
#[doc = " It MUST be a NULL-terminated not empty string."]
#[doc = " The content MUST be UTF-8 encoded (this implies ASCII encoding is also allowed)."]
pub name: *const ::std::os::raw::c_char,
#[doc = " The version of the EVMC VM implementation, e.g. \"1.2.3b4\"."]
#[doc = ""]
#[doc = " It MUST be a NULL-terminated not empty string."]
#[doc = " The content MUST be UTF-8 encoded (this implies ASCII encoding is also allowed)."]
pub version: *const ::std::os::raw::c_char,
#[doc = " Pointer to function destroying the VM instance."]
#[doc = ""]
#[doc = " This is a mandatory method and MUST NOT be set to NULL."]
pub destroy: evmc_destroy_fn,
#[doc = " Pointer to function executing a code by the VM instance."]
#[doc = ""]
#[doc = " This is a mandatory method and MUST NOT be set to NULL."]
pub execute: evmc_execute_fn,
#[doc = " A method returning capabilities supported by the VM instance."]
#[doc = ""]
#[doc = " The value returned MAY change when different options are set via the set_option() method."]
#[doc = ""]
#[doc = " A Client SHOULD only rely on the value returned if it has queried it after"]
#[doc = " it has called the set_option()."]
#[doc = ""]
#[doc = " This is a mandatory method and MUST NOT be set to NULL."]
pub get_capabilities: evmc_get_capabilities_fn,
#[doc = " Optional pointer to function modifying VM's options."]
#[doc = ""]
#[doc = " If the VM does not support this feature the pointer can be NULL."]
pub set_option: evmc_set_option_fn,
}
#[test]
fn bindgen_test_layout_evmc_vm() {
assert_eq!(
::std::mem::size_of::<evmc_vm>(),
56usize,
concat!("Size of: ", stringify!(evmc_vm))
);
assert_eq!(
::std::mem::align_of::<evmc_vm>(),
8usize,
concat!("Alignment of ", stringify!(evmc_vm))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_vm>())).abi_version as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(evmc_vm),
"::",
stringify!(abi_version)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_vm>())).name as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(evmc_vm),
"::",
stringify!(name)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_vm>())).version as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(evmc_vm),
"::",
stringify!(version)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_vm>())).destroy as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(evmc_vm),
"::",
stringify!(destroy)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_vm>())).execute as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(evmc_vm),
"::",
stringify!(execute)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_vm>())).get_capabilities as *const _ as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(evmc_vm),
"::",
stringify!(get_capabilities)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evmc_vm>())).set_option as *const _ as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(evmc_vm),
"::",
stringify!(set_option)
)
);
}