-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpp: Add Host interface for the Host side #226
Conversation
2cbd68b
to
886cecc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
examples/example_host.cpp
Outdated
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, | ||
public: | ||
bool account_exists(const evmc_address& addr) noexcept override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be final
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I noticed. Decided to go override
because more common. I tend to not to use less common C++ features in examples. Although, in this case it might be good suggestion to use final
here.
include/evmc/evmc.hpp
Outdated
/// Wrapper around EVMC host context / host interface. | ||
class host | ||
/// | ||
/// To be used by VM implementations as better alternative than using ::evmc_context directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternative to
include/evmc/evmc.hpp
Outdated
{ | ||
context->host->emit_log(context, &address, data, data_size, topics, topics_count); | ||
} | ||
}; | ||
|
||
/// Abstract class to be used by Host implementations. Hides ::evmc_context vtable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation here could be better. evmc_context
doesn't have vtable.
Better explicitly point out, that this class should be derived when implementing Host
886cecc
to
a0d0591
Compare
a0d0591
to
0c1e13b
Compare
This adds the Host part of the C++ API.
The plan was different, to keep it physically separated, but I realized both Host and VM sides of the API implement the same interface...
HostInterface
.This introduces some naming issues. We have
HostInterface
as pure C++ interfaceHostContext
as wrapper for the host context pointer to be used by VMs, implementsHostInterface
.Host
- the abstract class for Host implementations, implementsHostInterface
.Suggestions for better names welcome.
Effectively closes #189.
The only tunes left for C++ are aliases like
evmc::address = evmc_address
, merging helpers.hpp, maybe add better types forevmc_address
,evmc_uint256be
, etc.