EVMC
evmc::HostContext Class Reference

Wrapper around EVMC host context / host interface. More...

#include <evmc.hpp>

Inheritance diagram for evmc::HostContext:
evmc::HostInterface

Public Member Functions

 HostContext ()=default
 Default constructor for null Host context.
 
 HostContext (const evmc_host_interface &interface, evmc_host_context *ctx) noexcept
 Constructor from the EVMC Host primitives.
 
bool account_exists (const address &address) const noexcept final
 Check account existence callback function.
 
bytes32 get_storage (const address &address, const bytes32 &key) const noexcept final
 Get storage callback function.
 
evmc_storage_status set_storage (const address &address, const bytes32 &key, const bytes32 &value) noexcept final
 Set storage callback function.
 
uint256be get_balance (const address &address) const noexcept final
 Get balance callback function.
 
size_t get_code_size (const address &address) const noexcept final
 Get code size callback function.
 
bytes32 get_code_hash (const address &address) const noexcept final
 Get code hash callback function.
 
size_t copy_code (const address &address, size_t code_offset, uint8_t *buffer_data, size_t buffer_size) const noexcept final
 Copy code callback function.
 
bool selfdestruct (const address &addr, const address &beneficiary) noexcept final
 Selfdestruct callback function.
 
Result call (const evmc_message &message) noexcept final
 Call callback function.
 
evmc_tx_context get_tx_context () const noexcept final
 Get transaction context callback function.
 
bytes32 get_block_hash (int64_t number) const noexcept final
 Get block hash callback function.
 
void emit_log (const address &addr, const uint8_t *data, size_t data_size, const bytes32 topics[], size_t topics_count) noexcept final
 Emit log callback function.
 
evmc_access_status access_account (const address &address) noexcept final
 Access account callback function.
 
evmc_access_status access_storage (const address &address, const bytes32 &key) noexcept final
 Access storage callback function.
 
bytes32 get_transient_storage (const address &address, const bytes32 &key) const noexcept final
 Get transient storage callback function.
 
void set_transient_storage (const address &address, const bytes32 &key, const bytes32 &value) noexcept final
 Set transient storage callback function.
 
virtual bool account_exists (const address &addr) const noexcept=0
 Check account existence callback function.
 
virtual bytes32 get_storage (const address &addr, const bytes32 &key) const noexcept=0
 Get storage callback function.
 
virtual evmc_storage_status set_storage (const address &addr, const bytes32 &key, const bytes32 &value) noexcept=0
 Set storage callback function.
 
virtual uint256be get_balance (const address &addr) const noexcept=0
 Get balance callback function.
 
virtual size_t get_code_size (const address &addr) const noexcept=0
 Get code size callback function.
 
virtual bytes32 get_code_hash (const address &addr) const noexcept=0
 Get code hash callback function.
 
virtual size_t copy_code (const address &addr, size_t code_offset, uint8_t *buffer_data, size_t buffer_size) const noexcept=0
 Copy code callback function.
 
virtual bool selfdestruct (const address &addr, const address &beneficiary) noexcept=0
 Selfdestruct callback function.
 
virtual Result call (const evmc_message &msg) noexcept=0
 Call callback function.
 
virtual evmc_tx_context get_tx_context () const noexcept=0
 Get transaction context callback function.
 
virtual bytes32 get_block_hash (int64_t block_number) const noexcept=0
 Get block hash callback function.
 
virtual void emit_log (const address &addr, const uint8_t *data, size_t data_size, const bytes32 topics[], size_t num_topics) noexcept=0
 Emit log callback function.
 
virtual evmc_access_status access_account (const address &addr) noexcept=0
 Access account callback function.
 
virtual evmc_access_status access_storage (const address &addr, const bytes32 &key) noexcept=0
 Access storage callback function.
 
virtual bytes32 get_transient_storage (const address &addr, const bytes32 &key) const noexcept=0
 Get transient storage callback function.
 
virtual void set_transient_storage (const address &addr, const bytes32 &key, const bytes32 &value) noexcept=0
 Set transient storage callback function.
 

Detailed Description

Wrapper around EVMC host context / host interface.

To be used by VM implementations as better alternative to using evmc_host_context directly.

Definition at line 511 of file evmc.hpp.

Constructor & Destructor Documentation

◆ HostContext()

evmc::HostContext::HostContext ( const evmc_host_interface interface,
evmc_host_context ctx 
)
inlinenoexcept

Constructor from the EVMC Host primitives.

Parameters
interfaceThe reference to the Host interface.
ctxThe pointer to the Host context object. This parameter MAY be null.

Definition at line 523 of file evmc.hpp.

524 : host{&interface}, context{ctx}
525 {}

Member Function Documentation

◆ access_account()

evmc_access_status evmc::HostContext::access_account ( const address addr)
inlinefinalvirtualnoexcept

Access account callback function.

Implements evmc::HostInterface.

Definition at line 594 of file evmc.hpp.

595 {
596 return host->access_account(context, &address);
597 }
evmc_access_account_fn access_account
Access account callback function.
Definition: evmc.h:883

◆ access_storage()

evmc_access_status evmc::HostContext::access_storage ( const address addr,
const bytes32 key 
)
inlinefinalvirtualnoexcept

Access storage callback function.

Implements evmc::HostInterface.

Definition at line 599 of file evmc.hpp.

600 {
601 return host->access_storage(context, &address, &key);
602 }
evmc_access_storage_fn access_storage
Access storage callback function.
Definition: evmc.h:886

◆ account_exists()

bool evmc::HostContext::account_exists ( const address addr) const
inlinefinalvirtualnoexcept

Check account existence callback function.

Implements evmc::HostInterface.

Definition at line 527 of file evmc.hpp.

528 {
529 return host->account_exists(context, &address);
530 }
evmc_account_exists_fn account_exists
Check account existence callback function.
Definition: evmc.h:847

◆ call()

Result evmc::HostContext::call ( const evmc_message msg)
inlinefinalvirtualnoexcept

Call callback function.

Implements evmc::HostInterface.

Definition at line 572 of file evmc.hpp.

573 {
574 return Result{host->call(context, &message)};
575 }
evmc_call_fn call
Call callback function.
Definition: evmc.h:871

◆ copy_code()

size_t evmc::HostContext::copy_code ( const address addr,
size_t  code_offset,
uint8_t *  buffer_data,
size_t  buffer_size 
) const
inlinefinalvirtualnoexcept

Copy code callback function.

Implements evmc::HostInterface.

Definition at line 559 of file evmc.hpp.

563 {
564 return host->copy_code(context, &address, code_offset, buffer_data, buffer_size);
565 }
evmc_copy_code_fn copy_code
Copy code callback function.
Definition: evmc.h:865

◆ emit_log()

void evmc::HostContext::emit_log ( const address addr,
const uint8_t *  data,
size_t  data_size,
const bytes32  topics[],
size_t  num_topics 
)
inlinefinalvirtualnoexcept

Emit log callback function.

Implements evmc::HostInterface.

Definition at line 585 of file evmc.hpp.

590 {
591 host->emit_log(context, &addr, data, data_size, topics, topics_count);
592 }
evmc_emit_log_fn emit_log
Emit log callback function.
Definition: evmc.h:880

◆ get_balance()

uint256be evmc::HostContext::get_balance ( const address addr) const
inlinefinalvirtualnoexcept

Get balance callback function.

Implements evmc::HostInterface.

Definition at line 544 of file evmc.hpp.

545 {
546 return host->get_balance(context, &address);
547 }
evmc_get_balance_fn get_balance
Get balance callback function.
Definition: evmc.h:856

◆ get_block_hash()

bytes32 evmc::HostContext::get_block_hash ( int64_t  block_number) const
inlinefinalvirtualnoexcept

Get block hash callback function.

Implements evmc::HostInterface.

Definition at line 580 of file evmc.hpp.

581 {
582 return host->get_block_hash(context, number);
583 }
evmc_get_block_hash_fn get_block_hash
Get block hash callback function.
Definition: evmc.h:877

◆ get_code_hash()

bytes32 evmc::HostContext::get_code_hash ( const address addr) const
inlinefinalvirtualnoexcept

Get code hash callback function.

Implements evmc::HostInterface.

Definition at line 554 of file evmc.hpp.

555 {
556 return host->get_code_hash(context, &address);
557 }
evmc_get_code_hash_fn get_code_hash
Get code hash callback function.
Definition: evmc.h:862

◆ get_code_size()

size_t evmc::HostContext::get_code_size ( const address addr) const
inlinefinalvirtualnoexcept

Get code size callback function.

Implements evmc::HostInterface.

Definition at line 549 of file evmc.hpp.

550 {
551 return host->get_code_size(context, &address);
552 }
evmc_get_code_size_fn get_code_size
Get code size callback function.
Definition: evmc.h:859

◆ get_storage()

bytes32 evmc::HostContext::get_storage ( const address addr,
const bytes32 key 
) const
inlinefinalvirtualnoexcept

Get storage callback function.

Implements evmc::HostInterface.

Definition at line 532 of file evmc.hpp.

533 {
534 return host->get_storage(context, &address, &key);
535 }
evmc_get_storage_fn get_storage
Get storage callback function.
Definition: evmc.h:850

◆ get_transient_storage()

bytes32 evmc::HostContext::get_transient_storage ( const address addr,
const bytes32 key 
) const
inlinefinalvirtualnoexcept

Get transient storage callback function.

Implements evmc::HostInterface.

Definition at line 604 of file evmc.hpp.

605 {
606 return host->get_transient_storage(context, &address, &key);
607 }
evmc_get_transient_storage_fn get_transient_storage
Get transient storage callback function.
Definition: evmc.h:889

◆ get_tx_context()

evmc_tx_context evmc::HostContext::get_tx_context ( ) const
inlinefinalvirtualnoexcept

Get transaction context callback function.

Implements evmc::HostInterface.

Definition at line 578 of file evmc.hpp.

578{ return host->get_tx_context(context); }
evmc_get_tx_context_fn get_tx_context
Get transaction context callback function.
Definition: evmc.h:874

◆ selfdestruct()

bool evmc::HostContext::selfdestruct ( const address addr,
const address beneficiary 
)
inlinefinalvirtualnoexcept

Selfdestruct callback function.

Implements evmc::HostInterface.

Definition at line 567 of file evmc.hpp.

568 {
569 return host->selfdestruct(context, &addr, &beneficiary);
570 }
evmc_selfdestruct_fn selfdestruct
Selfdestruct callback function.
Definition: evmc.h:868

◆ set_storage()

evmc_storage_status evmc::HostContext::set_storage ( const address addr,
const bytes32 key,
const bytes32 value 
)
inlinefinalvirtualnoexcept

Set storage callback function.

Implements evmc::HostInterface.

Definition at line 537 of file evmc.hpp.

540 {
541 return host->set_storage(context, &address, &key, &value);
542 }
evmc_set_storage_fn set_storage
Set storage callback function.
Definition: evmc.h:853

◆ set_transient_storage()

void evmc::HostContext::set_transient_storage ( const address addr,
const bytes32 key,
const bytes32 value 
)
inlinefinalvirtualnoexcept

Set transient storage callback function.

Implements evmc::HostInterface.

Definition at line 609 of file evmc.hpp.

612 {
613 host->set_transient_storage(context, &address, &key, &value);
614 }
evmc_set_transient_storage_fn set_transient_storage
Set transient storage callback function.
Definition: evmc.h:892

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