From 0bf52fec4db412f5cbb2124b58f4b4c6b6d77939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 7 Feb 2025 12:45:38 +0100 Subject: [PATCH] Add EXPERIMENTAL revision (#728) Add new `EVMC_EXPERIMENTAL` to `evmc_revision` to allow EVM implementations to expose experimental features. --- bindings/go/evmc/evmc.go | 1 + bindings/go/evmc/evmc_test.go | 2 +- include/evmc/evmc.h | 16 +++++++++++----- include/evmc/helpers.h | 2 ++ lib/instructions/instruction_metrics.c | 1 + lib/instructions/instruction_names.c | 1 + test/unittests/cpp_test.cpp | 1 + 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bindings/go/evmc/evmc.go b/bindings/go/evmc/evmc.go index c0817e129..4e347387d 100644 --- a/bindings/go/evmc/evmc.go +++ b/bindings/go/evmc/evmc.go @@ -112,6 +112,7 @@ const ( Cancun Revision = C.EVMC_CANCUN Prague Revision = C.EVMC_PRAGUE Osaka Revision = C.EVMC_OSAKA + Experimental Revision = C.EVMC_EXPERIMENTAL MaxRevision Revision = C.EVMC_MAX_REVISION LatestStableRevision Revision = C.EVMC_LATEST_STABLE_REVISION ) diff --git a/bindings/go/evmc/evmc_test.go b/bindings/go/evmc/evmc_test.go index 0c00772a4..8c63fa3a6 100644 --- a/bindings/go/evmc/evmc_test.go +++ b/bindings/go/evmc/evmc_test.go @@ -64,7 +64,7 @@ func TestExecuteEmptyCode(t *testing.T) { } func TestRevision(t *testing.T) { - if MaxRevision != Osaka { + if MaxRevision != Experimental { t.Errorf("missing constant for revision %d", MaxRevision) } if LatestStableRevision != Cancun { diff --git a/include/evmc/evmc.h b/include/evmc/evmc.h index 4fc513f7a..1786db87e 100644 --- a/include/evmc/evmc.h +++ b/include/evmc/evmc.h @@ -1034,21 +1034,27 @@ enum evmc_revision EVMC_CANCUN = 12, /** - * The Prague revision. + * The Prague / Pectra revision. * - * The future next revision after Cancun. + * https://eips.ethereum.org/EIPS/eip-7600 */ EVMC_PRAGUE = 13, /** - * The Osaka revision. + * The Osaka / Fusaka revision. * - * The future next revision after Prague. + * https://eips.ethereum.org/EIPS/eip-7607 */ EVMC_OSAKA = 14, + /** + * The unspecified EVM revision used for EVM implementations to expose + * experimental features. + */ + EVMC_EXPERIMENTAL = 15, + /** The maximum EVM revision supported. */ - EVMC_MAX_REVISION = EVMC_OSAKA, + EVMC_MAX_REVISION = EVMC_EXPERIMENTAL, /** * The latest known EVM revision with finalized specification. diff --git a/include/evmc/helpers.h b/include/evmc/helpers.h index a5f6c3637..c237f69d4 100644 --- a/include/evmc/helpers.h +++ b/include/evmc/helpers.h @@ -303,6 +303,8 @@ static inline const char* evmc_revision_to_string(enum evmc_revision rev) return "Prague"; case EVMC_OSAKA: return "Osaka"; + case EVMC_EXPERIMENTAL: + return "Experimental"; } return ""; } diff --git a/lib/instructions/instruction_metrics.c b/lib/instructions/instruction_metrics.c index 41eb34c15..670c4f013 100644 --- a/lib/instructions/instruction_metrics.c +++ b/lib/instructions/instruction_metrics.c @@ -3146,6 +3146,7 @@ const struct evmc_instruction_metrics* evmc_get_instruction_metrics_table( { switch (revision) { + case EVMC_EXPERIMENTAL: case EVMC_OSAKA: return osaka_metrics; case EVMC_PRAGUE: diff --git a/lib/instructions/instruction_names.c b/lib/instructions/instruction_names.c index 6e05b238b..83501ab28 100644 --- a/lib/instructions/instruction_names.c +++ b/lib/instructions/instruction_names.c @@ -2857,6 +2857,7 @@ const char* const* evmc_get_instruction_names_table(enum evmc_revision revision) { switch (revision) { + case EVMC_EXPERIMENTAL: case EVMC_OSAKA: return osaka_names; case EVMC_PRAGUE: diff --git a/test/unittests/cpp_test.cpp b/test/unittests/cpp_test.cpp index b0ca20e72..9c93cee66 100644 --- a/test/unittests/cpp_test.cpp +++ b/test/unittests/cpp_test.cpp @@ -919,6 +919,7 @@ TEST(cpp, revision_to_string) TEST_CASE(EVMC_CANCUN), TEST_CASE(EVMC_PRAGUE), TEST_CASE(EVMC_OSAKA), + TEST_CASE(EVMC_EXPERIMENTAL), }; #undef TEST_CASE