Skip to content
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

Abort on unknown eosevm version #120

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eosevm/assert.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#define EOSEVM_ABORT(msg) silkworm::abort_due_to_assertion_failure(msg, __FILE__, __LINE__)
arhag marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 6 additions & 2 deletions eosevm/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

#include <silkworm/core/types/block.hpp>
#include <silkworm/core/common/endian.hpp>

#include <eosevm/assert.hpp>
namespace eosevm {

static constexpr uint64_t max_eos_evm_version = 1;

using NonceType=silkworm::BlockHeader::NonceType;

inline NonceType version_to_nonce(uint64_t version) {
Expand All @@ -22,8 +24,10 @@ inline evmc_revision version_to_evmc_revision(uint64_t version) {
switch (version) {
case 0: return EVMC_ISTANBUL;
case 1: return EVMC_ISTANBUL;
default: return EVMC_ISTANBUL;
}
auto msg = "Unknown EOSEVM version: " + std::to_string(version);
EOSEVM_ABORT(msg.c_str());
return static_cast<evmc_revision>(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider encapsulating that into a macro, something like EOS_ASSERT(msg) in a header file and then you can use it elsewhere as needed.

}

} // namespace eosevm