mirror of https://github.com/status-im/evmc.git
Merge pull request #302 from ethereum/cpp_execute_without_context
C++: Add execute() overloading without evmc_context parameter
This commit is contained in:
commit
0c2a99fb4c
|
@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning].
|
|||
[[#372](https://github.com/ethereum/evmc/pull/372)]
|
||||
- The **Berlin** EVM revision has been added.
|
||||
[[#407](https://github.com/ethereum/evmc/pull/407)]
|
||||
- In C++ API, an overload for `VM::execute()` has been added that omits
|
||||
the Host context and interface parameters. This is useful for Precompiles VMs
|
||||
that do not interact with the Host.
|
||||
[[#302](https://github.com/ethereum/evmc/pull/302)]
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -408,6 +408,23 @@ public:
|
|||
return result{m_instance->execute(m_instance, &host, ctx, rev, &msg, code, code_size)};
|
||||
}
|
||||
|
||||
/// Executes code without the Host context.
|
||||
///
|
||||
/// The same as
|
||||
/// execute(const evmc_host_interface&, evmc_host_context*, evmc_revision,
|
||||
/// const evmc_message&, const uint8_t*, size_t),
|
||||
/// but without providing the Host context and interface.
|
||||
/// This method is for experimental precompiles support where execution is
|
||||
/// guaranteed not to require any Host access.
|
||||
result execute(evmc_revision rev,
|
||||
const evmc_message& msg,
|
||||
const uint8_t* code,
|
||||
size_t code_size) noexcept
|
||||
{
|
||||
return result{
|
||||
m_instance->execute(m_instance, nullptr, nullptr, rev, &msg, code, code_size)};
|
||||
}
|
||||
|
||||
private:
|
||||
evmc_vm* m_instance = nullptr;
|
||||
};
|
||||
|
|
|
@ -358,8 +358,7 @@ TEST(cpp, vm_execute_precompiles)
|
|||
msg.input_size = input.size();
|
||||
msg.gas = 18;
|
||||
|
||||
constexpr evmc_host_interface null_interface{};
|
||||
auto res = vm.execute(null_interface, nullptr, EVMC_MAX_REVISION, msg, nullptr, 0);
|
||||
auto res = vm.execute(EVMC_MAX_REVISION, msg, nullptr, 0);
|
||||
EXPECT_EQ(res.status_code, EVMC_SUCCESS);
|
||||
EXPECT_EQ(res.gas_left, 0);
|
||||
ASSERT_EQ(res.output_size, input.size());
|
||||
|
|
Loading…
Reference in New Issue