Template Class internal_operations#

Class Documentation#

template<class params>
class internal_operations#

The internal operations class. It contains the implementation of the internal operations. 50s: Stack, Memory, Storage and Flow Operations:

  • MLOAD

  • MSTORE

  • MSTORE8

  • SLOAD

  • SSTORE

  • JUMP

  • JUMPI

  • PC

  • MSIZE

  • GAS

  • JUMPDEST POP moved to stack_operations a0s: Logging Operations:

  • LOGX

Public Types

typedef arith_env_t<params> arith_t#

The arithmetical environment used by the arbitrary length integer library.

typedef arith_t::bn_t bn_t#

The arbitrary length integer type.

typedef stack_t<params> stack_t#

The stackk class.

typedef block_t<params> block_t#

The block class.

typedef touch_state_t<params> touch_state_t#

The touch state class.

typedef memory_t<params> memory_t#

The memory class.

typedef transaction_t<params> transaction_t#

The transaction class.

typedef message_t<params> message_t#

The message class.

typedef log_state_t<params> log_state_t#

The logs state class.

Public Static Functions

static inline __host__ __device__ __forceinline__ void operation_MLOAD (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, memory_t &memory)

The MLOAD operation implementation. Takes the memory offset from the stack and push the evm word from the memory at the given memory offset. Adittional gas cost is added for the memory expansion.

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.

  • memory[in] The memory.

static inline __host__ __device__ __forceinline__ void operation_MSTORE (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, memory_t &memory)

The MSTORE operation implementation. Takes the memory offset and the value from the stack and stores the value in the memory at the given memory offset. Adittional gas cost is added for the memory expansion.

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[in] The stack.

  • memory[out] The memory.

static inline __host__ __device__ __forceinline__ void operation_MSTORE8 (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, memory_t &memory)

The MSTORE8 operation implementation. Takes the memory offset and the value from the stack and stores the least significant byte of the value in the memory at the given memory offset. Adittional gas cost is added for the memory expansion.

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[in] The stack.

  • memory[out] The memory.

static inline __host__ __device__ __forceinline__ void operation_SLOAD (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, touch_state_t &touch_state, message_t &message)

The SLOAD operation implementation. Takes the key from the stack and push the value from the storage at the given key. Adittional gas cost is added for the storage access, if the key is warm or cold. The storage is given by the message 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.

  • pc[inout] The program counter.

  • stack[inout] The stack.

  • touch_state[in] The touch state.

  • message[in] The message that started the execution.

static inline __host__ __device__ __forceinline__ void operation_SSTORE (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, bn_t &gas_refund, uint32_t &error_code, uint32_t &pc, stack_t &stack, touch_state_t &touch_state, message_t &message)

The SSTORE operation implementation. Takes the key and the value from the stack and stores the value in the storage at the given key. Adittional gas cost is added depending on the value and if the key is warm or cold. The storage is given by the message call. Depending on the value the refund gas is updated.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • gas_refund[inout] The gas refund.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[in] The stack.

  • touch_state[out] The touch state.

  • message[in] The message that started the execution.

static inline __host__ __device__ __forceinline__ void operation_JUMP (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, jump_destinations_t &jumpdest)

The JUMP operation implementation. Takes the destination from the stack and sets the program counter to the destination if it is a valid jump destination.

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[in] The stack.

  • jumpdest[in] The jump destinations.

static inline __host__ __device__ __forceinline__ void operation_JUMPI (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, jump_destinations_t &jumpdest)

The JUMPI operation implementation. Takes the destination and the condition from the stack and sets the program counter to the destination if it is a valid jump destination and the condition is not 0. If the condition is 0 the program counter is incremented by 1.

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[in] The stack.

  • jumpdest[in] The jump destinations.

static inline __host__ __device__ __forceinline__ void operation_PC (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The PC operation implementation. Pushes the program counter to the stack.

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[out] The stack.

static inline __host__ __device__ __forceinline__ void operation_MSIZE (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, memory_t &memory)

The MSIZE operation implementation. Pushes the memory size to the stack.

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[out] The stack.

  • memory[in] The memory.

static inline __host__ __device__ __forceinline__ void operation_GAS (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The GAS operation implementation. Pushes the gas left to the stack after this 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[out] The stack.

static inline __host__ __device__ __forceinline__ void operation_JUMPDEST (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc)

The JUMPDEST operation implementation. It increments the program counter by 1. It is used as a valid jump destination.

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.

static inline __host__ __device__ __forceinline__ void operation_LOGX (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, memory_t &memory, message_t &message, log_state_t &log_state, uint8_t &opcode)

The LOGX operation implementation. Takes the memory offset, the memory length and the topics from the stack and stores the memory data togheter with the topics in the logs. Adittional gas cost is added for the memory expansion and for the topics. Every byte of memory costs additional GAS_LOG_DATA gas. Every topic costs additional GAS_LOG_TOPIC gas.

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[in] The stack.

  • memory[in] The memory.

  • message[in] The message that started the execution.

  • log_state[out] The logs state.

  • opcode[in] The opcode.

Public Static Attributes

static const uint32_t HASH_BYTES = 32#

The number of bytes in a hash.