Skip to content

Commit

Permalink
Merge pull request #125 from ethereum/host-interface
Browse files Browse the repository at this point in the history
Host interface
  • Loading branch information
chfast committed Aug 31, 2018
2 parents 3a3aef2 + e2cff68 commit 4d86207
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bindings/go/evmc/evmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct extended_context
int64_t index;
};
extern const struct evmc_context_fn_table evmc_go_fn_table;
extern const struct evmc_host_interface evmc_go_host;
static struct evmc_result execute_wrapper(struct evmc_instance* instance, int64_t context_index, enum evmc_revision rev,
const struct evmc_address* destination, const struct evmc_address* sender, const struct evmc_uint256be* value,
Expand All @@ -51,7 +51,7 @@ static struct evmc_result execute_wrapper(struct evmc_instance* instance, int64_
flags,
};
struct extended_context ctx = {{&evmc_go_fn_table}, context_index};
struct extended_context ctx = {{&evmc_go_host}, context_index};
return evmc_execute(instance, &ctx.context, rev, &msg, code, code_size);
}
*/
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/evmc/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void evmc_go_free_result_output(const struct evmc_result* result)
* problem the go_exported_functions_type_checks() function simulates usage
* of Go exported functions with expected types to check them during compilation.
*/
const struct evmc_context_fn_table evmc_go_fn_table = {
const struct evmc_host_interface evmc_go_host = {
(evmc_account_exists_fn)accountExists,
(evmc_get_storage_fn)getStorage,
(evmc_set_storage_fn)setStorage,
Expand Down
4 changes: 2 additions & 2 deletions examples/example_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ static void emit_log(evmc_context* context,
(void)topics_count;
}

static const evmc_context_fn_table methods = {
static const evmc_host_interface interface = {
account_exists, get_storage, set_storage, get_balance, get_code_size, get_code_hash,
copy_code, selfdestruct, call, get_tx_context, get_block_hash, emit_log,
};

struct example_host_context : evmc_context
{
example_host_context() : evmc_context{&methods} {}
example_host_context() : evmc_context{&interface} {}
};

extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions examples/example_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ static struct evmc_result execute(struct evmc_instance* instance,
{
struct evmc_uint256be value;
const struct evmc_uint256be index = {{0}};
context->fn_table->get_storage(&value, context, &msg->destination, &index);
context->host->get_storage(&value, context, &msg->destination, &index);
value.bytes[31]++;
context->fn_table->set_storage(context, &msg->destination, &index, &value);
context->host->set_storage(context, &msg->destination, &index, &value);
ret.status_code = EVMC_SUCCESS;
return ret;
}
Expand Down
16 changes: 8 additions & 8 deletions include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,14 @@ typedef struct evmc_result (*evmc_call_fn)(struct evmc_context* context,
const struct evmc_message* msg);

/**
* The context interface.
* The Host interface.
*
* The set of all callback functions expected by EVM instances. This is C
* realisation of vtable for OOP interface (only virtual methods, no data).
* Host implementations SHOULD create constant singletons of this (similarly
* to vtables) to lower the maintenance and memory management cost.
* The set of all callback functions expected by VM instances. This is C
* realisation of vtable for OOP interface (only virtual methods, no data).
* Host implementations SHOULD create constant singletons of this (similarly
* to vtables) to lower the maintenance and memory management cost.
*/
struct evmc_context_fn_table
struct evmc_host_interface
{
/** Check account existence callback function. */
evmc_account_exists_fn account_exists;
Expand Down Expand Up @@ -638,8 +638,8 @@ struct evmc_context_fn_table
*/
struct evmc_context
{
/** Function table defining the context interface (vtable). */
const struct evmc_context_fn_table* fn_table;
/** The Host interface. */
const struct evmc_host_interface* host;
};


Expand Down

0 comments on commit 4d86207

Please sign in to comment.