From d167bc0a24c88a84e7e53b60b2bfd4a062dad84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 10 Feb 2022 15:09:27 +0100 Subject: [PATCH 1/2] Update links to execution specs for revisions --- include/evmc/evmc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/evmc/evmc.h b/include/evmc/evmc.h index eafff68ac..cfddacd6b 100644 --- a/include/evmc/evmc.h +++ b/include/evmc/evmc.h @@ -868,21 +868,21 @@ enum evmc_revision /** * The Berlin revision. * - * https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md + * https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md */ EVMC_BERLIN = 8, /** * The London revision. * - * https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/london.md + * https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md */ EVMC_LONDON = 9, /** * The Shanghai revision. * - * https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md + * https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md */ EVMC_SHANGHAI = 10, From 3123de80ffa00b2c9d7d8a5e638091f603880476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 10 Feb 2022 15:17:56 +0100 Subject: [PATCH 2/2] Add Merge revision --- CHANGELOG.md | 3 +++ include/evmc/evmc.h | 9 ++++++++- include/evmc/helpers.h | 2 ++ lib/instructions/instruction_metrics.c | 1 + lib/instructions/instruction_names.c | 1 + test/unittests/cpp_test.cpp | 1 + test/unittests/instructions_test.cpp | 22 ++++++++++++++++++---- 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb4728e0..afd9c598b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning]. ### Added +- The [Merge](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/merge.md) + EVM revision. + [#627](https://github.com/ethereum/evmc/pull/627) - The error code `EVMC_LOADER_UNSPECIFIED_ERROR` has been defined to provide a convenient way of initializing `evmc_loader_error_code` objects. [#617](https://github.com/ethereum/evmc/pull/617) diff --git a/include/evmc/evmc.h b/include/evmc/evmc.h index cfddacd6b..3a8cb9845 100644 --- a/include/evmc/evmc.h +++ b/include/evmc/evmc.h @@ -879,12 +879,19 @@ enum evmc_revision */ EVMC_LONDON = 9, + /** + * The Merge revision. + * + * https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/merge.md + */ + EVMC_MERGE = 10, + /** * The Shanghai revision. * * https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md */ - EVMC_SHANGHAI = 10, + EVMC_SHANGHAI = 11, /** The maximum EVM revision supported. */ EVMC_MAX_REVISION = EVMC_SHANGHAI, diff --git a/include/evmc/helpers.h b/include/evmc/helpers.h index 7c707945e..9ebdc746a 100644 --- a/include/evmc/helpers.h +++ b/include/evmc/helpers.h @@ -284,6 +284,8 @@ static inline const char* evmc_revision_to_string(enum evmc_revision rev) return "Berlin"; case EVMC_LONDON: return "London"; + case EVMC_MERGE: + return "Merge"; case EVMC_SHANGHAI: return "Shanghai"; } diff --git a/lib/instructions/instruction_metrics.c b/lib/instructions/instruction_metrics.c index c2b71fc54..03d6ade9b 100644 --- a/lib/instructions/instruction_metrics.c +++ b/lib/instructions/instruction_metrics.c @@ -2108,6 +2108,7 @@ const struct evmc_instruction_metrics* evmc_get_instruction_metrics_table( switch (revision) { case EVMC_SHANGHAI: + case EVMC_MERGE: case EVMC_LONDON: return london_metrics; case EVMC_BERLIN: diff --git a/lib/instructions/instruction_names.c b/lib/instructions/instruction_names.c index 199dfcf64..f48da92a9 100644 --- a/lib/instructions/instruction_names.c +++ b/lib/instructions/instruction_names.c @@ -1563,6 +1563,7 @@ const char* const* evmc_get_instruction_names_table(enum evmc_revision revision) switch (revision) { case EVMC_SHANGHAI: + case EVMC_MERGE: case EVMC_LONDON: return london_names; case EVMC_BERLIN: diff --git a/test/unittests/cpp_test.cpp b/test/unittests/cpp_test.cpp index 3fe51e262..e92a26ecd 100644 --- a/test/unittests/cpp_test.cpp +++ b/test/unittests/cpp_test.cpp @@ -860,6 +860,7 @@ TEST(cpp, revision_to_string) TEST_CASE(EVMC_ISTANBUL), TEST_CASE(EVMC_BERLIN), TEST_CASE(EVMC_LONDON), + TEST_CASE(EVMC_MERGE), TEST_CASE(EVMC_SHANGHAI), }; #undef TEST_CASE diff --git a/test/unittests/instructions_test.cpp b/test/unittests/instructions_test.cpp index f9c0c2c1a..abd06e0dc 100644 --- a/test/unittests/instructions_test.cpp +++ b/test/unittests/instructions_test.cpp @@ -352,16 +352,30 @@ TEST(instructions, london_hard_fork) EXPECT_TRUE(bn[OP_BASEFEE] == nullptr); } +TEST(instructions, merge_hard_fork) +{ + const auto m = evmc_get_instruction_metrics_table(EVMC_MERGE); + const auto l = evmc_get_instruction_metrics_table(EVMC_LONDON); + const auto mn = evmc_get_instruction_names_table(EVMC_MERGE); + const auto ln = evmc_get_instruction_names_table(EVMC_LONDON); + + for (int op = 0x00; op <= 0xff; ++op) + { + EXPECT_EQ(m[op], l[op]) << op; + EXPECT_STREQ(mn[op], ln[op]) << op; + } +} + TEST(instructions, shanghai_hard_fork) { const auto s = evmc_get_instruction_metrics_table(EVMC_SHANGHAI); - const auto l = evmc_get_instruction_metrics_table(EVMC_LONDON); + const auto m = evmc_get_instruction_metrics_table(EVMC_MERGE); const auto sn = evmc_get_instruction_names_table(EVMC_SHANGHAI); - const auto ln = evmc_get_instruction_names_table(EVMC_LONDON); + const auto mn = evmc_get_instruction_names_table(EVMC_MERGE); for (int op = 0x00; op <= 0xff; ++op) { - EXPECT_EQ(s[op], l[op]) << op; - EXPECT_STREQ(sn[op], ln[op]) << op; + EXPECT_EQ(s[op], m[op]) << op; + EXPECT_STREQ(sn[op], mn[op]) << op; } }