From 0e80c10b48e0b1119396252bef3544b203cd7f91 Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Thu, 18 Jan 2024 01:40:04 -0300 Subject: [PATCH 1/4] Abort on unknown eosevm version --- eosevm/version.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eosevm/version.hpp b/eosevm/version.hpp index 5e027b54..27a52706 100644 --- a/eosevm/version.hpp +++ b/eosevm/version.hpp @@ -22,8 +22,14 @@ 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); + #ifdef ANTELOPE + eosio::check(false, msg.c_str()); + #else + silkworm::abort_due_to_assertion_failure(msg.c_str(), __FILE__, __LINE__); + #endif + return static_cast(0); } } // namespace eosevm \ No newline at end of file From c9d247b4823d942a9fd6536f168af57fd7218eef Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Thu, 18 Jan 2024 02:35:47 -0300 Subject: [PATCH 2/4] Add max_eos_evm_version constant --- eosevm/version.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eosevm/version.hpp b/eosevm/version.hpp index 27a52706..99dc6e71 100644 --- a/eosevm/version.hpp +++ b/eosevm/version.hpp @@ -2,9 +2,13 @@ #include #include - +#ifdef ANTELOPE +#include +#endif namespace eosevm { +static constexpr uint64_t max_eos_evm_version = 1; + using NonceType=silkworm::BlockHeader::NonceType; inline NonceType version_to_nonce(uint64_t version) { From 8b8e25e6dbce2473927e789794b9916e84f9f0e5 Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Thu, 18 Jan 2024 13:27:03 -0300 Subject: [PATCH 3/4] Add eosevm::abort function --- eosevm/assert.hpp | 18 ++++++++++++++++++ eosevm/version.hpp | 10 ++-------- 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 eosevm/assert.hpp diff --git a/eosevm/assert.hpp b/eosevm/assert.hpp new file mode 100644 index 00000000..e6b3cd0a --- /dev/null +++ b/eosevm/assert.hpp @@ -0,0 +1,18 @@ +#pragma once +#ifdef ANTELOPE +#include +#else +#include +#endif + +namespace eosevm { + +static void abort(const char* msg) { + #ifdef ANTELOPE + eosio::check(false, msg); + #else + silkworm::abort_due_to_assertion_failure(msg, __FILE__, __LINE__); + #endif +} + +} diff --git a/eosevm/version.hpp b/eosevm/version.hpp index 99dc6e71..1207668d 100644 --- a/eosevm/version.hpp +++ b/eosevm/version.hpp @@ -2,9 +2,7 @@ #include #include -#ifdef ANTELOPE -#include -#endif +#include namespace eosevm { static constexpr uint64_t max_eos_evm_version = 1; @@ -28,11 +26,7 @@ inline evmc_revision version_to_evmc_revision(uint64_t version) { case 1: return EVMC_ISTANBUL; } auto msg = "Unknown EOSEVM version: " + std::to_string(version); - #ifdef ANTELOPE - eosio::check(false, msg.c_str()); - #else - silkworm::abort_due_to_assertion_failure(msg.c_str(), __FILE__, __LINE__); - #endif + eosevm::abort(msg.c_str()); return static_cast(0); } From d0def379c6c967ee0546474a45572d0334341f0b Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Thu, 18 Jan 2024 13:32:16 -0300 Subject: [PATCH 4/4] Simplify eosevm abort function --- eosevm/assert.hpp | 18 +----------------- eosevm/version.hpp | 2 +- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/eosevm/assert.hpp b/eosevm/assert.hpp index e6b3cd0a..feedac40 100644 --- a/eosevm/assert.hpp +++ b/eosevm/assert.hpp @@ -1,18 +1,2 @@ #pragma once -#ifdef ANTELOPE -#include -#else -#include -#endif - -namespace eosevm { - -static void abort(const char* msg) { - #ifdef ANTELOPE - eosio::check(false, msg); - #else - silkworm::abort_due_to_assertion_failure(msg, __FILE__, __LINE__); - #endif -} - -} +#define EOSEVM_ABORT(msg) silkworm::abort_due_to_assertion_failure(msg, __FILE__, __LINE__) diff --git a/eosevm/version.hpp b/eosevm/version.hpp index 1207668d..3e123f5a 100644 --- a/eosevm/version.hpp +++ b/eosevm/version.hpp @@ -26,7 +26,7 @@ inline evmc_revision version_to_evmc_revision(uint64_t version) { case 1: return EVMC_ISTANBUL; } auto msg = "Unknown EOSEVM version: " + std::to_string(version); - eosevm::abort(msg.c_str()); + EOSEVM_ABORT(msg.c_str()); return static_cast(0); }