Skip to content

Commit

Permalink
Merge pull request #567 from ethereum/statetests-branch
Browse files Browse the repository at this point in the history
Support Cancun and Prague revisions in state tests
  • Loading branch information
gumb0 authored Feb 20, 2023
2 parents 937d79d + 25a72fe commit 09851dd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/evmone/instructions_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ constexpr inline GasCostTable gas_costs = []() noexcept {
table[EVMC_CANCUN][OP_DUPN] = 3;
table[EVMC_CANCUN][OP_SWAPN] = 3;

table[EVMC_PRAGUE] = table[EVMC_CANCUN];

return table;
}();

Expand Down
2 changes: 1 addition & 1 deletion test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DUP1,4
add_test(NAME ${PREFIX}/trace COMMAND $<TARGET_FILE:evmc::tool> --vm $<TARGET_FILE:evmone>,trace run 60006002800103)
set_tests_properties(
${PREFIX}/trace PROPERTIES PASS_REGULAR_EXPRESSION
"{\"depth\":0,\"rev\":\"London\",\"static\":false}
"{\"depth\":0,\"rev\":\"Paris\",\"static\":false}
{\"pc\":0,\"op\":96,\"opName\":\"PUSH1\",\"gas\":1000000,\"stack\":\\[\\],\"memorySize\":0}
{\"pc\":2,\"op\":96,\"opName\":\"PUSH1\",\"gas\":999997,\"stack\":\\[\"0x0\"\\],\"memorySize\":0}
{\"pc\":4,\"op\":128,\"opName\":\"DUP1\",\"gas\":999994,\"stack\":\\[\"0x0\",\"0x2\"\\],\"memorySize\":0}
Expand Down
4 changes: 4 additions & 0 deletions test/statetest/statetest_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ evmc_revision to_rev(std::string_view s)
return EVMC_SHANGHAI;
if (s == "Shanghai")
return EVMC_SHANGHAI;
if (s == "Cancun")
return EVMC_CANCUN;
if (s == "Prague")
return EVMC_PRAGUE;
throw std::invalid_argument{"unknown revision: " + std::string{s}};
}

Expand Down
2 changes: 1 addition & 1 deletion test/unittests/instructions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ TEST(instructions, compare_with_evmc_instruction_tables)
{
// Skip DUPN and SWAPN for Cancun. They are not defined in evmc
// TODO: Define DUPN and SWAPN in evmc
if (r == EVMC_CANCUN && (Opcode(i) == OP_DUPN || Opcode(i) == OP_SWAPN))
if (r >= EVMC_CANCUN && (Opcode(i) == OP_DUPN || Opcode(i) == OP_SWAPN))
continue;
const auto gas_cost = (instr_tbl[i] != instr::undefined) ? instr_tbl[i] : 0;
const auto& metrics = evmone_tbl[i];
Expand Down

0 comments on commit 09851dd

Please sign in to comment.