OpenCBDC Transaction Processor
|
Implementation of the evmc::Host interface using PARSEC as the backend database. More...
#include <host.hpp>
Public Types | |
using | indexed_logs_type = std::unordered_map<evmc::address, std::vector<evm_log>> |
Public Member Functions | |
evm_host (std::shared_ptr< logging::log > log, interface::try_lock_callback_type try_lock_callback, evmc_tx_context tx_context, evm_tx tx, bool is_readonly_run, interface::ticket_number_type ticket_number) | |
Constructs a new host instance. | |
auto | account_exists (const evmc::address &addr) const noexcept -> bool override |
auto | get_storage (const evmc::address &addr, const evmc::bytes32 &key) const noexcept -> evmc::bytes32 override final |
auto | set_storage (const evmc::address &addr, const evmc::bytes32 &key, const evmc::bytes32 &value) noexcept -> evmc_storage_status override final |
auto | get_balance (const evmc::address &addr) const noexcept -> evmc::uint256be override final |
auto | get_code_size (const evmc::address &addr) const noexcept -> size_t override final |
auto | get_code_hash (const evmc::address &addr) const noexcept -> evmc::bytes32 override final |
auto | copy_code (const evmc::address &addr, size_t code_offset, uint8_t *buffer_data, size_t buffer_size) const noexcept -> size_t override final |
auto | selfdestruct (const evmc::address &addr, const evmc::address &beneficiary) noexcept -> bool override final |
auto | call (const evmc_message &msg) noexcept -> evmc::Result override final |
auto | get_tx_context () const noexcept -> evmc_tx_context override final |
auto | get_block_hash (int64_t number) const noexcept -> evmc::bytes32 override final |
void | emit_log (const evmc::address &addr, const uint8_t *data, size_t data_size, const evmc::bytes32 topics[], size_t topics_count) noexcept override final |
auto | access_account (const evmc::address &addr) noexcept -> evmc_access_status override final |
auto | access_storage (const evmc::address &addr, const evmc::bytes32 &key) noexcept -> evmc_access_status override final |
auto | get_log_index_keys () const -> std::vector< cbdc::buffer > |
Return the keys of the log indexes - these are sha256(addr, ticket) and will get value 1 - to indicate there are logs for the given address in the given ticket. | |
auto | get_state_updates () const -> runtime_locking_shard::state_update_type |
Return the changes to the state resulting from transaction execution. | |
auto | should_retry () const -> bool |
Returns whether the transaction needs to be retried due to a transient error. | |
void | insert_account (const evmc::address &addr, const evm_account &acc) |
Inserts an account into the host. | |
void | finalize (int64_t gas_left, int64_t gas_used) |
Finalizes the state updates resulting from the transaction. | |
void | revert () |
Set the state updates to revert the transaction changes due to a contract error. | |
auto | ticket_number_key (std::optional< interface::ticket_number_type > tn=std::nullopt) const -> cbdc::buffer |
Return the key for the host's ticket number, which is the hash of the ticket number's serialized representation to uniformly distribute all ticket-to-tx mappings across the shards. | |
auto | log_index_key (evmc::address addr, std::optional< interface::ticket_number_type > tn=std::nullopt) const -> cbdc::buffer |
Return the key for the indicator of the existence of logs for a particular address at a particular ticket. | |
Implementation of the evmc::Host interface using PARSEC as the backend database.
Manages the cached state during contract execution to support committing the final state updates or reverting while still charging gas. Undocumented functions below are inhereted from evmc::Host and are documented upstream.
using cbdc::parsec::agent::runner::evm_host::indexed_logs_type = std::unordered_map<evmc::address, std::vector<evm_log>> |
cbdc::parsec::agent::runner::evm_host::evm_host | ( | std::shared_ptr< logging::log > | log, |
interface::try_lock_callback_type | try_lock_callback, | ||
evmc_tx_context | tx_context, | ||
evm_tx | tx, | ||
bool | is_readonly_run, | ||
interface::ticket_number_type | ticket_number ) |
Constructs a new host instance.
log | log instance. |
try_lock_callback | function for requesting locks on keys. |
tx_context | evmc context in which the transaction will execute. |
tx | transaction to execute. |
is_readonly_run | true if no state changes should be applied. |
ticket_number | ticket number for transaction. |
Definition at line 23 of file host.cpp.
References cbdc::parsec::agent::runner::evm_tx_receipt::m_ticket_number, and cbdc::parsec::agent::runner::evm_tx_receipt::m_tx.
|
finaloverridenoexcept |
Definition at line 404 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
|
finaloverridenoexcept |
Definition at line 414 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
|
nodiscardoverridenoexcept |
Definition at line 83 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
|
finaloverridenoexcept |
Definition at line 308 of file host.cpp.
References cbdc::buffer, cbdc::parsec::agent::runner::to_hex(), and cbdc::parsec::transfer.
|
finaloverridenoexcept |
Definition at line 192 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
|
finaloverridenoexcept |
void cbdc::parsec::agent::runner::evm_host::finalize | ( | int64_t | gas_left, |
int64_t | gas_used ) |
Finalizes the state updates resulting from the transaction.
gas_left | remaining unspent gas. |
gas_used | total gas consumed by the transaction. |
Definition at line 576 of file host.cpp.
References cbdc::parsec::agent::runner::evm_tx_receipt::m_gas_used, and cbdc::parsec::agent::runner::evm_tx_receipt::m_timestamp.
|
nodiscardfinaloverridenoexcept |
Definition at line 150 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
|
nodiscardfinaloverridenoexcept |
|
nodiscardfinaloverridenoexcept |
Definition at line 175 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
|
nodiscardfinaloverridenoexcept |
Definition at line 162 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
auto cbdc::parsec::agent::runner::evm_host::get_log_index_keys | ( | ) | const -> std::vector<cbdc::buffer> |
Return the keys of the log indexes - these are sha256(addr, ticket) and will get value 1 - to indicate there are logs for the given address in the given ticket.
The logs for the specific ticket can then be fetched and filtered on topic and address.
Definition at line 460 of file host.cpp.
References log_index_key().
auto cbdc::parsec::agent::runner::evm_host::get_state_updates | ( | ) | const -> runtime_locking_shard::state_update_type |
Return the changes to the state resulting from transaction execution.
Definition at line 481 of file host.cpp.
References cbdc::buffer, log_index_key(), cbdc::make_buffer(), ticket_number_key(), and cbdc::parsec::agent::runner::tx_id().
|
nodiscardfinaloverridenoexcept |
Definition at line 95 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
|
nodiscardfinaloverridenoexcept |
void cbdc::parsec::agent::runner::evm_host::insert_account | ( | const evmc::address & | addr, |
const evm_account & | acc ) |
auto cbdc::parsec::agent::runner::evm_host::log_index_key | ( | evmc::address | addr, |
std::optional< interface::ticket_number_type > | tn = std::nullopt ) const -> cbdc::buffer |
Return the key for the indicator of the existence of logs for a particular address at a particular ticket.
Definition at line 443 of file host.cpp.
References cbdc::make_buffer().
Referenced by get_log_index_keys(), and get_state_updates().
void cbdc::parsec::agent::runner::evm_host::revert | ( | ) |
|
finaloverridenoexcept |
Definition at line 217 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex(), and cbdc::parsec::transfer.
|
finaloverridenoexcept |
Definition at line 104 of file host.cpp.
References cbdc::parsec::agent::runner::to_hex().
auto cbdc::parsec::agent::runner::evm_host::should_retry | ( | ) | const -> bool |
auto cbdc::parsec::agent::runner::evm_host::ticket_number_key | ( | std::optional< interface::ticket_number_type > | tn = std::nullopt | ) | const -> cbdc::buffer |
Return the key for the host's ticket number, which is the hash of the ticket number's serialized representation to uniformly distribute all ticket-to-tx mappings across the shards.
Definition at line 427 of file host.cpp.
References cbdc::make_buffer().
Referenced by get_state_updates().