Add Shanghai revision
MODIFY
include/evmc/evmc.h
include/evmc/evmc.h
@@ -832,8 +832,15 @@ enum evmc_revision
*/
EVMC_LONDON = 9,
+ /**
+ * The Shanghai revision.
+ *
+ * https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md
+ */
+ EVMC_SHANGHAI = 10,
+
/** The maximum EVM revision supported. */
- EVMC_MAX_REVISION = EVMC_LONDON
+ EVMC_MAX_REVISION = EVMC_SHANGHAI
};

MODIFY
include/evmc/helpers.h
include/evmc/helpers.h
@@ -285,6 +285,8 @@ static inline const char* evmc_revision_to_string(enum evmc_revision rev)
return "Berlin";
case EVMC_LONDON:
return "London";
+ case EVMC_SHANGHAI:
+ return "Shanghai";
}
return "<unknown>";
}

MODIFY
lib/instructions/instruction_metrics.c
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_LONDON:
return london_metrics;
case EVMC_BERLIN:

MODIFY
lib/instructions/instruction_names.c
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_LONDON:
return london_names;
case EVMC_BERLIN:

MODIFY
test/unittests/cpp_test.cpp
test/unittests/cpp_test.cpp
@@ -848,6 +848,7 @@ TEST(cpp, revision_to_string)
TEST_CASE(EVMC_ISTANBUL),
TEST_CASE(EVMC_BERLIN),
TEST_CASE(EVMC_LONDON),
+ TEST_CASE(EVMC_SHANGHAI),
};
#undef TEST_CASE

MODIFY
test/unittests/instructions_test.cpp
test/unittests/instructions_test.cpp
@@ -352,3 +352,17 @@ TEST(instructions, london_hard_fork)
EXPECT_EQ(ln[OP_BASEFEE], std::string{"BASEFEE"});
EXPECT_TRUE(bn[OP_BASEFEE] == nullptr);
}
+
+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 sn = evmc_get_instruction_names_table(EVMC_SHANGHAI);
+ const auto ln = evmc_get_instruction_names_table(EVMC_LONDON);
+
+ for (int op{OP_STOP}; op <= OP_SELFDESTRUCT; ++op)
+ {
+ EXPECT_EQ(s[op], l[op]) << op;
+ EXPECT_STREQ(sn[op], ln[op]) << op;
+ }
+}

Add Shanghai revision