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

Add Shanghai revision #604

Merged
merged 2 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};


Expand Down
2 changes: 2 additions & 0 deletions include/evmc/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>";
}
Expand Down
1 change: 1 addition & 0 deletions lib/instructions/instruction_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions lib/instructions/instruction_names.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions test/unittests/cpp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions test/unittests/instructions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

Still think this should go by 0x00 .. 0xff and not the instruction names.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, added here.

{
EXPECT_EQ(s[op], l[op]) << op;
EXPECT_STREQ(sn[op], ln[op]) << op;
}
}