EVMC
evmc::MockedHost Class Reference

Mocked EVMC Host implementation. More...

#include <mocked_host.hpp>

Inherits evmc::Host.

Classes

struct  log_record
 LOG record. More...
 
struct  selfdestuct_record
 SELFDESTRUCT record. More...
 

Public Member Functions

void record_account_access (const address &addr) const
 Record an account access. More...
 
bool account_exists (const address &addr) const noexcept override
 Returns true if an account exists (EVMC Host method).
 
bytes32 get_storage (const address &addr, const bytes32 &key) const noexcept override
 Get the account's storage value at the given key (EVMC Host method).
 
evmc_storage_status set_storage (const address &addr, const bytes32 &key, const bytes32 &value) noexcept override
 Set the account's storage value (EVMC Host method).
 
uint256be get_balance (const address &addr) const noexcept override
 Get the account's balance (EVMC Host method).
 
size_t get_code_size (const address &addr) const noexcept override
 Get the account's code size (EVMC host method).
 
bytes32 get_code_hash (const address &addr) const noexcept override
 Get the account's code hash (EVMC host method).
 
size_t copy_code (const address &addr, size_t code_offset, uint8_t *buffer_data, size_t buffer_size) const noexcept override
 Copy the account's code to the given buffer (EVMC host method).
 
void selfdestruct (const address &addr, const address &beneficiary) noexcept override
 Selfdestruct the account (EVMC host method).
 
result call (const evmc_message &msg) noexcept override
 Call/create other contract (EVMC host method).
 
evmc_tx_context get_tx_context () const noexcept override
 Get transaction context (EVMC host method).
 
bytes32 get_block_hash (int64_t block_number) const noexcept override
 Get the block header hash (EVMC host method).
 
void emit_log (const address &addr, const uint8_t *data, size_t data_size, const bytes32 topics[], size_t topics_count) noexcept override
 Emit LOG (EVMC host method).
 
- Public Member Functions inherited from evmc::Host
evmc_host_contextto_context () noexcept
 Converts the Host object to the opaque host context pointer. More...
 

Public Attributes

std::unordered_map< address, MockedAccountaccounts
 The set of all accounts in the Host, organized by their addresses.
 
evmc_tx_context tx_context = {}
 The EVMC transaction context to be returned by get_tx_context().
 
bytes32 block_hash = {}
 The block header hash value to be returned by get_block_hash().
 
evmc_result call_result = {}
 The call result to be returned by the call() method.
 
std::vector< int64_t > recorded_blockhashes
 The record of all block numbers for which get_block_hash() was called.
 
std::vector< addressrecorded_account_accesses
 The record of all account accesses.
 
std::vector< evmc_messagerecorded_calls
 The record of all call messages requested in the call() method.
 
std::vector< log_recordrecorded_logs
 The record of all LOGs passed to the emit_log() method.
 
std::vector< selfdestuct_recordrecorded_selfdestructs
 The record of all SELFDESTRUCTs from the selfdestruct() method.
 

Static Public Attributes

static constexpr auto max_recorded_account_accesses = 200
 The maximum number of entries in recorded_account_accesses record. More...
 
static constexpr auto max_recorded_calls = 100
 The maximum number of entries in recorded_calls record. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from evmc::Host
static const evmc_host_interfaceget_interface () noexcept
 Provides access to the global host interface. More...
 
template<typename DerivedClass = Host>
static DerivedClass * from_context (evmc_host_context *context) noexcept
 Converts the opaque host context pointer back to the original Host object. More...
 

Detailed Description

Mocked EVMC Host implementation.

Definition at line 63 of file mocked_host.hpp.

Member Function Documentation

◆ record_account_access()

void evmc::MockedHost::record_account_access ( const address addr) const
inline

Record an account access.

Parameters
addrThe address of the accessed account.

Definition at line 143 of file mocked_host.hpp.

144  {
145  if (recorded_account_accesses.empty())
147 
149  recorded_account_accesses.emplace_back(addr);
150  }
static constexpr auto max_recorded_account_accesses
The maximum number of entries in recorded_account_accesses record.
std::vector< address > recorded_account_accesses
The record of all account accesses.

Member Data Documentation

◆ max_recorded_account_accesses

constexpr auto evmc::MockedHost::max_recorded_account_accesses = 200
static

The maximum number of entries in recorded_account_accesses record.

This is arbitrary value useful in fuzzing when we don't want the record to explode.

Definition at line 121 of file mocked_host.hpp.

◆ max_recorded_calls

constexpr auto evmc::MockedHost::max_recorded_calls = 100
static

The maximum number of entries in recorded_calls record.

This is arbitrary value useful in fuzzing when we don't want the record to explode.

Definition at line 128 of file mocked_host.hpp.


The documentation for this class was generated from the following file: