Template Class evm_t#
Defined in File evm.cuh
Nested Relationships#
Nested Types#
Class Documentation#
-
template<class params>
class evm_t# Public Types
-
typedef arith_env_t<params> arith_t#
The arithmetical environment used by the arbitrary length integer library.
-
typedef world_state_t<params> world_state_t#
World state information class.
-
typedef world_state_t::state_data_t state_data_t#
World state information data type.
-
typedef world_state_t::account_t account_t#
The account information data.
-
typedef accessed_state_t<params> accessed_state_t#
The access state class.
-
typedef accessed_state_t::accessed_state_data_t accessed_state_data_t#
The access state data type.
-
typedef touch_state_t<params> touch_state_t#
The touch state class.
-
typedef touch_state_t::touch_state_data_t touch_state_data_t#
The touch state data type.
-
typedef transaction_t<params> transaction_t#
The transaction class.
-
typedef transaction_t::transaction_data_t transaction_data_t#
The transaction content data structure.
-
typedef log_state_t<params> log_state_t#
The logs state class.
-
typedef log_state_t::log_state_data_t log_state_data_t#
The logs state data type.
-
typedef arithmetic_operations<params> arithmetic_operations#
The arithmetic operations class.
-
typedef comparison_operations<params> comparison_operations#
The comparison operations class.
-
typedef bitwise_operations<params> bitwise_operations#
The bitwise operations class.
-
typedef stack_operations<params> stack_operations#
The stack operations class.
-
typedef block_operations<params> block_operations#
The block operations class.
-
typedef environmental_operations<params> environmental_operations#
The environmental operations class.
-
typedef internal_operations<params> internal_operations#
The internal operations class.
Public Functions
- inline __host__ __device__ __forceinline__ evm_t (arith_t arith, state_data_t *world_state_data, block_data_t *block_data, sha3_parameters_t *sha3_parameters, transaction_data_t *transaction_data, accessed_state_data_t *accessed_state_data, touch_state_data_t *touch_state_data, log_state_data_t *log_state_data, #ifdef TRACER tracer_data_t *tracer_data, #endif uint32_t instance, uint32_t *error)
The cosntructor for an evm instance.
- Parameters
arith – [in] The arithmetical environment.
world_state_data – [in] The world state data.
block_data – [in] The block data.
sha3_parameters – [in] The sha3 parameters.
transaction_data – [in] The transaction data.
accessed_state_data – [out] The accessed state data.
touch_state_data – [out] The touch state data.
log_state_data – [out] The log state data.
tracer_data – [out] The tracer data.
instance – [in] The instance number.
error – [out] The error code.
- Returns
The evm instance.
- inline __host__ __device__ __forceinline__ ~evm_t ()
The destructor for an evm instance.
- inline __host__ __device__ __forceinline__ void grow ()
Increase the allocation depth of the evm instance.
- inline __host__ __device__ void start_TRANSACTION (bn_t &gas_used, uint32_t &error_code)
Init the evm instance for starting the transaction execution. Finds the gas price, priority fee, total gas limit and initialiased the gas used with the transaction initialisation gas cost. Verify if is it a valid transaction. Warm up the coinbase account.
- Parameters
gas_used – YP: \(g_{0}\)
gas_used – [out] The gas used.
error_code – [out] The error code.
- inline __host__ __device__ void update_CALL ()
Update the evm instance for the current depth message call. It updates the gas limit, the bytecode, the code size and the jump destinations.
- inline __host__ __device__ void start_CALL (uint32_t &error_code)
Starts a new message call execution. It update the evm instance for the current message call. It allocate the memory, the stack, the touch state, the log state, the return data. It sends the value from the sender to the receiver, and warms up the accounts.
- Parameters
error_code – [out] The error code.
- inline __host__ __device__ void run (uint32_t &error_code)
Run the transaction execution.
- Parameters
error_code – [out] The error code.
- inline __host__ __device__ __forceinline__ void finish_CREATEX (uint32_t &error_code)
Finish the CREATEX operation
- Parameters
error_code – [out] error code
- inline __host__ __device__ __forceinline__ void finish_CALL (uint32_t &error_code)
Finish the CALL operation or CREATE CALL operation.
- Parameters
error_code – [out] error code
- inline __host__ __device__ __forceinline__ void free_CALL ()
Free the memory allocated for the CALL/CREATEX operation.
- inline __host__ __device__ __forceinline__ void finish_TRANSACTION (uint32_t &error_code)
Finish the transaction.
- Parameters
error_code – [out] error code
- inline __host__ __device__ __forceinline__ void child_CALL (uint32_t &error_code, message_t &new_message)
Make a CALL/CREATEX call by increasing the depth.
- Parameters
error_code – [out] error code
new_message – [in] new message call
Public Members
-
world_state_t *_world_state#
The world state
-
transaction_t *_transaction#
The current transaction
-
accessed_state_t *_accessed_state#
The accessed state
-
touch_state_t *_transaction_touch_state#
The final touch state of the transaction
-
log_state_t *_transaction_log_state#
The final log state of the transaction
-
uint32_t _instance#
The current instance/transaction number
-
uint32_t _trace_pc#
The current program counter
-
uint8_t _trace_opcode#
The current opcode
-
touch_state_t **_touch_state_ptrs#
The touch states for every depth call
-
log_state_t **_log_state_ptrs#
The log states for every depth call
-
return_data_t **_last_return_data_ptrs#
The last return data for every depth call
-
return_data_t *_final_return_data#
The final return data
-
uint32_t *_pcs#
The current program counter for every depth call
-
accessed_state_data_t *_final_accessed_state_data#
The final accessed state data
-
touch_state_data_t *_final_touch_state_data#
The final touch state data
-
log_state_data_t *_final_log_state_data#
The final log state data
-
uint32_t _depth#
The current depth
-
uint32_t _allocated_depth#
The allocated depth
-
uint8_t *_bytecode#
The current executing code YP: \(I_{b}\)
-
uint32_t _code_size#
The current executing code size
-
uint8_t _opcode#
The current opcode
-
jump_destinations_t *_jump_destinations#
The jump destinations for the current execution context
-
uint32_t _error_code#
The error code
-
uint32_t *_final_error#
The final error code
Public Static Functions
- static inline __host__ void get_cpu_instances (evm_instances_t &instances, const cJSON *test)
Get the cpu instances from the json test.
- Parameters
instances – [out] evm instances
test – [in] json test
- static inline __host__ void get_gpu_instances (evm_instances_t &gpu_instances, evm_instances_t &cpu_instances)
Get the gpu instances from the cpu instances.
- Parameters
gpu_instances – [out] evm instances
cpu_instances – [in] evm instances
- static inline __host__ void get_cpu_instances_from_gpu_instances (evm_instances_t &cpu_instances, evm_instances_t &gpu_instances)
Get the cpu instances from the gpu instances.
- Parameters
cpu_instances – [out] evm instances
gpu_instances – [in] evm instances
- static inline __host__ void free_instances (evm_instances_t &cpu_instances)
Free the cpu instances.
- Parameters
cpu_instances – [in] evm instances
- static inline __host__ void print_evm_instances_t (arith_t &arith, evm_instances_t instances)
Print the evm instances after the transaction execution.
- Parameters
arith – [in] arithmetic environment
instances – [in] evm instances
- static inline __host__ cJSON * json_from_evm_instances_t (arith_t &arith, evm_instances_t instances)
Get the json from the evm instances after the transaction execution.
- Parameters
arith – [in] arithmetic environment
instances – [in] evm instances
- Returns
json
Public Static Attributes
-
static const uint32_t MAX_DEPTH = 1024#
The maximum call depth
-
static const uint32_t MAX_EXECUTION_STEPS = 30000#
maximum number of execution steps TODO: DELETE
-
static const uint32_t DEPTH_PAGE_SIZE = 32#
allocation size for depth variable like stack, memory, states, return data
-
static const uint32_t MAX_CODE_SIZE = 24576#
EIP-170 Maximum contract size
-
static const uint32_t MAX_INIT_CODE_SIZE = 2 * MAX_CODE_SIZE#
EIP-3860 Maximum initicode size
-
static const uint32_t HASH_BYTES = 32#
The numver of bytes in a hash.
-
struct evm_instances_t#
The evm instances data structure.
Public Members
-
state_data_t *world_state_data#
The world state content
-
block_data_t *block_data#
The current block infomation
-
sha3_parameters_t *sha3_parameters#
The constants for the KECCAK
-
transaction_data_t *transactions_data#
The transactions information
-
accessed_state_data_t *accessed_states_data#
The data cotaining the states access by the transactions execution
-
touch_state_data_t *touch_states_data#
The data containing the states modified by the transactions execution
-
log_state_data_t *logs_data#
The logs done by the transactions
-
tracer_data_t *tracers_data#
Tracer datas for debug
-
uint32_t *errors#
The the result of every transaction
-
size_t count#
The number of instances/transactions
-
state_data_t *world_state_data#
-
class system_operations#
The system operations class. It contains the implementation of the system operations. 00:
STOP f0s: System operations:
CREATE
CALL
CALLCODE
RETURN
DELEGATECALL
CREATE2
STATICCALL
REVERT
INVALID
SELFDESTRUCT
Public Static Functions
- static inline __host__ __device__ __forceinline__ int32_t valid_CALL (arith_t &arith, message_t &message, touch_state_t &touch_state)
Get if a message call is valid.
- Parameters
arith – [in] The arithmetical environment.
message – [in] The message call.
touch_state – [in] The touch state.
- Returns
1 if the message call is valid, 0 otherwise.
- static inline __host__ __device__ __forceinline__ int32_t valid_CREATE (arith_t &arith, message_t &message, touch_state_t &touch_state)
Get if a message create call is valid.
- Parameters
arith – [in] The arithmetical environment.
message – [in] The message call.
touch_state – [in] The touch state.
- Returns
1 if the message create call is valid, 0 otherwise.
- static inline __host__ __device__ __forceinline__ void generic_CALL (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, evm_t &evm, message_t &new_message, bn_t &args_offset, bn_t &args_size, return_data_t &return_data)
Make a generic call.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [in] The touch state.
evm – [out] The evm.
new_message – [in] The new message call.
args_offset – [in] The message offset for call data.
args_size – [in] The message size for call data.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void generic_CREATE (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, evm_t &evm, message_t &new_message, bn_t &args_offset, bn_t &args_size, return_data_t &return_data)
Make a generic create call.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [in] The touch state.
evm – [out] The evm.
new_message – [in] The new message call.
args_offset – [in] The message offset for init code.
args_size – [in] The message size for init code.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_STOP (return_data_t &return_data, uint32_t &error_code)
The STOP operation.
- Parameters
return_data – [out] The return data.
error_code – [out] The error code.
- static inline __host__ __device__ __forceinline__ void operation_CREATE (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, uint8_t &opcode, keccak_t &keccak, evm_t &evm, return_data_t &return_data)
The CREATE operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
pc – [inout] The program counter.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [in] The touch state.
opcode – [in] The operation opcode
keccak – [in] The keccak object.
evm – [out] The evm.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_CALL (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, uint8_t &opcode, evm_t &evm, return_data_t &return_data)
The CALL operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
pc – [inout] The program counter.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [inout] The touch state.
opcode – [in] The operation opcode
evm – [out] The evm.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_CALLCODE (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, uint8_t &opcode, evm_t &evm, return_data_t &return_data)
The CALLCODE operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
pc – [inout] The program counter.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [inout] The touch state.
opcode – [in] The operation opcode
evm – [out] The evm.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_RETURN (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, stack_t &stack, memory_t &memory, return_data_t &return_data)
The RETURN operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
stack – [in] The stack.
memory – [in] The memory.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_DELEGATECALL (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, uint8_t &opcode, evm_t &evm, return_data_t &return_data)
The DELEGATECALL operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
pc – [inout] The program counter.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [inout] The touch state.
opcode – [in] The operation opcode
evm – [out] The evm.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_CREATE2 (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, uint8_t &opcode, keccak_t &keccak, evm_t &evm, return_data_t &return_data)
The CREATE2 operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
pc – [inout] The program counter.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [inout] The touch state.
opcode – [in] The operation opcode
keccak – [in] The keccak object.
evm – [out] The evm.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_STATICCALL (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, message_t &message, memory_t &memory, touch_state_t &touch_state, uint8_t &opcode, evm_t &evm, return_data_t &return_data)
The STATICCALL operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
pc – [inout] The program counter.
stack – [inout] The stack.
message – [in] The current context message call.
memory – [in] The memory.
touch_state – [inout] The touch state.
opcode – [in] The operation opcode
evm – [out] The evm.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_REVERT (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, stack_t &stack, memory_t &memory, return_data_t &return_data)
The REVERT operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
stack – [in] The stack.
memory – [in] The memory.
return_data – [out] The return data.
- static inline __host__ __device__ __forceinline__ void operation_INVALID (uint32_t &error_code)
The INVALID operation.
- Parameters
error_code – [out] The error code.
- static inline __host__ __device__ __forceinline__ void operation_SELFDESTRUCT (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, message_t &message, touch_state_t &touch_state, return_data_t &return_data, evm_t &evm)
The SELFDESTRUCT operation.
- Parameters
arith – [in] The arithmetical environment.
gas_limit – [in] The gas limit.
gas_used – [inout] The gas used.
error_code – [out] The error code.
pc – [inout] The program counter.
stack – [inout] The stack.
message – [in] The current context message call.
touch_state – [inout] The touch state.
return_data – [out] The return data.
evm – [out] The evm.
-
typedef arith_env_t<params> arith_t#