Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #5267 from ethereum/evmc-helpers
Browse files Browse the repository at this point in the history
Display firendlier ABI version mismatch error in VMFactory
  • Loading branch information
chfast authored Sep 14, 2018
2 parents 5ad169e + 377208c commit 7a21bb3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libevm/EVMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace eth
EVM::EVM(evmc_instance* _instance) noexcept : m_instance(_instance)
{
assert(m_instance != nullptr);
assert(m_instance->abi_version == EVMC_ABI_VERSION);
assert(evmc_is_abi_compatible(m_instance));

// Set the options.
for (auto& pair : evmcOptions())
Expand All @@ -32,7 +32,7 @@ EVM::Result EVM::execute(ExtVMFace& _ext, int64_t gas)
_ext.data.data(), _ext.data.size(), toEvmC(_ext.codeHash), toEvmC(0x0_cppui256), gas,
static_cast<int32_t>(_ext.depth), kind, flags};
return EVM::Result{
m_instance->execute(m_instance, &_ext, mode, &msg, _ext.code.data(), _ext.code.size())};
evmc_execute(m_instance, &_ext, mode, &msg, _ext.code.data(), _ext.code.size())};
}

owning_bytes_ref EVMC::exec(u256& io_gas, ExtVMFace& _ext, const OnOpFunc& _onOp)
Expand Down
6 changes: 3 additions & 3 deletions libevm/EVMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class EVM
public:
explicit EVM(evmc_instance* _instance) noexcept;

~EVM() { m_instance->destroy(m_instance); }
~EVM() { evmc_destroy(m_instance); }

EVM(EVM const&) = delete;
EVM& operator=(EVM) = delete;

char const* name() const noexcept { return m_instance->name; }
char const* name() const noexcept { return evmc_vm_name(m_instance); }

char const* version() const noexcept { return m_instance->version; }
char const* version() const noexcept { return evmc_vm_version(m_instance); }

class Result
{
Expand Down
5 changes: 4 additions & 1 deletion libevm/VMFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void setVMKind(const std::string& _name)
}
}

// If not match for predefined VM names, try loading it as an EVMC VM DLL.
// If no match for predefined VM names, try loading it as an EVMC VM DLL.
evmc_loader_error_code ec;
g_evmcDll.reset(new EVMC{evmc_load_and_create(_name.c_str(), &ec)});
switch (ec)
Expand All @@ -97,6 +97,9 @@ void setVMKind(const std::string& _name)
case EVMC_LOADER_SYMBOL_NOT_FOUND:
BOOST_THROW_EXCEPTION(std::system_error(std::make_error_code(std::errc::invalid_seek),
"loading " + _name + " failed: EVMC create function not found"));
case EVMC_LOADER_ABI_VERSION_MISMATCH:
BOOST_THROW_EXCEPTION(std::system_error(std::make_error_code(std::errc::invalid_argument),
"loading " + _name + " failed: EVMC ABI version mismatch"));
default:
BOOST_THROW_EXCEPTION(
std::system_error(std::error_code(static_cast<int>(ec), std::generic_category()),
Expand Down

0 comments on commit 7a21bb3

Please sign in to comment.