Template Class touch_state_t#
Defined in File state.cuh
Nested Relationships#
Nested Types#
Class Documentation#
-
template<class params>
class touch_state_t# Class to represent the touch state. The touch state is the state which contains the acounts modified by the execution of the transaction. YP: accrued transaction substate \(A_{t}\) for touch accounts
Public Types
-
typedef world_state_t<params> world_state_t#
The world state type.
-
typedef world_state_t::arith_t arith_t#
The arithmetical environment used by the arbitrary length integer library.
-
typedef world_state_t::bn_t bn_t#
The arbitrary length integer type.
-
typedef world_state_t::evm_word_t evm_word_t#
The arbitrary length integer type used for the storage. It is defined as the EVM word type.
-
typedef world_state_t::contract_storage_t contract_storage_t#
The storage entry type.
-
typedef world_state_t::account_t account_t#
The account type.
-
typedef world_state_t::state_data_t state_data_t#
The state data type. Contains the accounts with their storage.
-
typedef accessed_state_t<params> accessed_state_t#
The accessed state data type. Contains the accounts with their storage and the read operations done on the accounts.
Public Functions
- inline __host__ __device__ __forceinline__ touch_state_t (touch_state_data_t *content, accessed_state_t *access_state, touch_state_t *parent_state)
Constructor with given content.
- Parameters
content – [in] The content of the touch state
access_state – [in] The accessed state
parent_state – [in] The parent touch state
- inline __host__ __device__ __forceinline__ touch_state_t (accessed_state_t *access_state, touch_state_t *parent_state)
Constructor with given accessed state and parent touch state.
- Parameters
access_state – [in] The accessed state
parent_state – [in] The parent touch state
- inline __host__ __device__ __forceinline__ ~touch_state_t ()
The destructor. It frees the memory allocated for the touch state.
- inline __host__ __device__ __forceinline__ size_t get_account_index (bn_t &address, uint32_t &error_code)
Get the index of the account with the given address.
- Parameters
address – [in] The address of the account
error_code – [out] The error code if the account does not exist
- Returns
The index of the account
- inline __host__ __device__ __forceinline__ void charge_gas_access_account (bn_t &address, bn_t &gas_used)
Get the gas for accessing the account with the given address.
- Parameters
address – [in] The address of the account
gas_used – [inout] The gas used after the access
- inline __host__ __device__ __forceinline__ void charge_gas_access_storage (bn_t &address, bn_t &key, bn_t &gas_used)
Get the gas for accessing the given storage key of the account with the given address.
- Parameters
address – [in] The address of the account
key – [in] The key of the storage
gas_used – [inout] The gas used after the access
- inline __host__ __device__ __forceinline__ account_t * get_account (bn_t &address, uint32_t read_type)
Get the account with the given address. If the account does not exist in the touch state, it is searched in the parent touch state and if it does not exist there (also their respective parant), it is searched in the accessed state. At the end, it set the read operation on the account in the accessed state.
- Parameters
address – [in] The address of the account
read_type – [out] The read type
- Returns
The account
- inline __host__ __device__ __forceinline__ void get_account_nonce (bn_t &address, bn_t &nonce)
Get the account nonce of the account with the given address.
- Parameters
address – [in] The address of the account
nonce – [out] The nonce of the account
- inline __host__ __device__ __forceinline__ void get_account_balance (bn_t &address, bn_t &balance)
Get the account balance of the account with the given address.
- Parameters
address – [in] The address of the account
balance – [out] The balance of the account
- inline __host__ __device__ __forceinline__ size_t get_account_code_size (bn_t &address)
Get the account code size of the account with the given address.
- Parameters
address – [in] The address of the account
- Returns
The code size of the account
- inline __host__ __device__ __forceinline__ uint8_t * get_account_code (bn_t &address)
Get the account code of the account with the given address.
- Parameters
address – [in] The address of the account
- Returns
The code of the account
- inline __host__ __device__ __forceinline__ uint8_t * get_account_code_data (bn_t &address, bn_t &index, bn_t &length, size_t &available_size)
Get the account code data at the given index for the given length of the account with the given address. If the index is greater than the code size, it returns NULL. If the length is greater than the code size - index, it returns the code data from index to the end of the code and sets the available size to the code size - index. Otherwise, it returns the code data from index to index + length and sets the available size to length.
- Parameters
address – [in] The address of the account
index – [in] The index of the code data
length – [in] The length of the code data
available_size – [out] The available size of the code data
- inline __host__ __device__ __forceinline__ size_t set_account (bn_t &address)
Get the index of the account given by the address, or if it does not exist, add it to the list of accounts, and return the index of the new account.
It setup the new account with the details from the most updated version in the parents or the accessed state (global).
- Parameters
address – [in] The address of the account
- inline __host__ __device__ __forceinline__ void set_account_nonce (bn_t &address, bn_t &nonce)
Set the account nonce of the account with the given address.
- Parameters
address – [in] The address of the account
nonce – [in] The nonce of the account
- inline __host__ __device__ __forceinline__ void set_account_balance (bn_t &address, bn_t &balance)
Set the account balance of the account with the given address.
- Parameters
address – [in] The address of the account
balance – [in] The balance of the account
- inline __host__ __device__ __forceinline__ void set_account_code (bn_t &address, uint8_t *code, size_t code_size)
Set the account code of the account with the given address.
- Parameters
address – [in] The address of the account
code – [in] The code of the account
code_size – [in] The size of the code of the account
- inline __host__ __device__ __forceinline__ size_t get_storage_index (account_t *account, bn_t &key, uint32_t &error_code)
Get the index of the storage inside the given account with the given key.
- Parameters
account – [in] The account
key – [in] The key of the storage
error_code – [out] The error code if the key is not found
- Returns
The index of the storage in the account
- inline __host__ __device__ __forceinline__ void get_value (bn_t &address, bn_t &key, bn_t &value)
Get the storage value of the account with the given address and the given key.
- Parameters
address – [in] The address of the account
key – [in] The key of the storage
value – [out] The value of the storage
- inline __host__ __device__ __forceinline__ void get_storage_set_gas_cost_gas_refund (bn_t &address, bn_t &key, bn_t &value, bn_t &gas_cost, bn_t &gas_refund)
Get the gas cost and gas refund for the storage set operation.
- Parameters
address – [in] The address of the account
key – [in] The key of the storage
value – [in] The new value for the storage
gas_cost – [out] The gas cost
gas_refund – [out] The gas refund
- inline __host__ __device__ __forceinline__ void charge_gas_set_storage (bn_t &address, bn_t &key, bn_t &value, bn_t &gas_used, bn_t &gas_refund)
Get the gas cost and gas refund for the storage set operation with the given value at the given storage key in the storage of the account with the given address.
- Parameters
address – [in] The address of the account
key – [in] The key of the storage
value – [in] The new value for the storage
gas_used – [inout] The gas cost
gas_refund – [inout] The gas refund
- inline __host__ __device__ __forceinline__ void set_value (bn_t &address, bn_t &key, bn_t &value)
Set the storage value for the given key in the storage of the account with the given address
- Parameters
address – [in] The address of the account
key – [in] The key of the storage
value – [in] The new value for the storage
- inline __host__ __device__ __forceinline__ void delete_account (bn_t &address)
Register the account for delete.
- Parameters
address – [in] The address of the account
- inline __host__ __device__ __forceinline__ int32_t is_empty_account (bn_t &address)
Get if the account with the given address is empty. An account is empty if it has zero balance, zero nonce and zero code size.
- Parameters
address – [in] The address of the account
- Returns
1 if the account is empty, 0 otherwise
- inline __host__ __device__ __forceinline__ int32_t is_delete_account (bn_t &address)
Get if the account with the given address is register for delete.
- Parameters
address – [in] The address of the account
- Returns
1 if the account is register for delete, 0 otherwise
- inline __host__ __device__ __forceinline__ int32_t is_alive_account (bn_t &address)
Get if the account with the given address exists.
- Parameters
address – [in] The address of the account
- Returns
1 if the account exists, 0 otherwise
- inline __host__ __device__ __forceinline__ int32_t is_contract (bn_t &address)
Get if the account with the given address is a contract.
- Parameters
address – [in] The address of the account
- Returns
1 if the account is a contract, 0 otherwise
- inline __host__ __device__ __forceinline__ void update_with_child_state (touch_state_t &child)
Update the current touch state with the touch state of a children
- Parameters
child – [in] The touch state of the child
- inline __host__ __device__ __forceinline__ void to_touch_state_data_t (touch_state_data_t &touch_state_data)
Copy the content of the touch state to the given touch state data.
- Parameters
touch_state_data – [out] The touch state data
- inline __host__ __device__ __forceinline__ void print ()
Print the state.
- inline __host__ __forceinline__ cJSON * json ()
Get json of the state
- Returns
The json of the state
Public Members
-
touch_state_data_t *_content#
The content of the touch state
-
accessed_state_t *_accessed_state#
The accessed state
-
touch_state_t *_parent_state#
The parent touch state
Public Static Functions
- static inline __host__ touch_state_data_t * get_cpu_instances (uint32_t count)
Generate the CPU instances of the touch state data.
- Parameters
count – [in] The number of instances
- static inline __host__ void free_cpu_instances (touch_state_data_t *cpu_instances, uint32_t count)
Free the CPU instances of the touch state data.
- Parameters
cpu_instances – [in] The CPU instances
count – [in] The number of instances
- static inline __host__ touch_state_data_t * get_gpu_instances_from_cpu_instances (touch_state_data_t *cpu_instances, uint32_t count)
Generate the GPU instances of the touch state data from the CPU counterparts.
- Parameters
cpu_instances – [in] The CPU instances
count – [in] The number of instances
- static inline __host__ void free_gpu_instances (touch_state_data_t *gpu_instances, uint32_t count)
Free the GPU instances of the touch state data.
- Parameters
gpu_instances – [in] The GPU instances
count – [in] The number of instances
- static inline __host__ touch_state_data_t * get_cpu_instances_from_gpu_instances (touch_state_data_t *gpu_instances, uint32_t count)
Get the CPU instances of the touch state data from the GPU counterparts.
- Parameters
gpu_instances – [in] The GPU instances
count – [in] The number of instances
- static inline __host__ __device__ __forceinline__ void print_touch_state_data_t (arith_t &arith, touch_state_data_t &touch_state_data)
Print the touch state data structure
- Parameters
arith – [in] The arithemtic instance
touch_state_data – [in] The touch state data
- static inline __host__ cJSON * json_from_touch_state_data_t (arith_t &arith, touch_state_data_t &touch_state_data)
Get json of the touch state data structure.
- Parameters
arith – [in] The arithemtic instance
touch_state_data – [in] The touch state data
- Returns
The json of the touch state data
-
struct touch_state_data_t#
The touch state data type. Contains the accounts with their storage and the write operations done on the accounts. The write operations can be: 0 - no, 1 - bytecode, 2 - balance, 4 - nonce, 8 - storage
-
typedef world_state_t<params> world_state_t#