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 Berlin HF #407

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning].

- Support for Istanbul CHAINID opcode. `chain_id` added to `evmc_tx_context` struct.
[[#375](https://github.com/ethereum/evmc/pull/375)]
- The **Berlin** EVM revision has been added.
[[#407](https://github.com/ethereum/evmc/pull/407)]

## [6.3.1] - 2019-08-19

Expand Down
10 changes: 9 additions & 1 deletion include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ enum evmc_revision
* The Petersburg revision.
*
* Other names: Constantinople2, ConstantinopleFix.
*
* https://eips.ethereum.org/EIPS/eip-1716
*/
EVMC_PETERSBURG = 6,
Expand All @@ -774,8 +775,15 @@ enum evmc_revision
*/
EVMC_ISTANBUL = 7,

/**
* The Berlin revision.
*
* The spec draft: https://eips.ethereum.org/EIPS/eip-2070.
*/
EVMC_BERLIN = 8,

/** The maximum EVM revision supported. */
EVMC_MAX_REVISION = EVMC_ISTANBUL,
EVMC_MAX_REVISION = EVMC_BERLIN,


/**
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 @@ -1581,6 +1581,7 @@ const struct evmc_instruction_metrics* evmc_get_instruction_metrics_table(
switch (revision)
{
case EVMC_ISTANBUL:
case EVMC_BERLIN:
return istanbul_metrics;
case EVMC_PETERSBURG:
case EVMC_CONSTANTINOPLE:
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 @@ -1305,6 +1305,7 @@ const char* const* evmc_get_instruction_names_table(enum evmc_revision revision)
switch (revision)
{
case EVMC_ISTANBUL:
case EVMC_BERLIN:
return istanbul_names;
case EVMC_PETERSBURG:
case EVMC_CONSTANTINOPLE:
Expand Down
14 changes: 14 additions & 0 deletions test/unittests/test_instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,17 @@ TEST(instructions, istanbul_hard_fork)
EXPECT_EQ(in[OP_CHAINID], std::string{"CHAINID"});
EXPECT_TRUE(pn[OP_CHAINID] == nullptr);
}

TEST(instructions, berlin_hard_fork)
{
const auto b = evmc_get_instruction_metrics_table(EVMC_BERLIN);
const auto i = evmc_get_instruction_metrics_table(EVMC_ISTANBUL);
const auto bn = evmc_get_instruction_names_table(EVMC_BERLIN);
const auto in = evmc_get_instruction_names_table(EVMC_ISTANBUL);

for (int op{OP_STOP}; op <= OP_SELFDESTRUCT; ++op)
{
EXPECT_EQ(b[op], i[op]) << op;
EXPECT_STREQ(bn[op], in[op]) << op;
}
}