Skip to content

Commit

Permalink
Merge pull request #309 from ethereum/evmc_upgrade
Browse files Browse the repository at this point in the history
Upgrade EVMC to 8.0.0
  • Loading branch information
chfast authored Apr 27, 2021
2 parents 3361221 + 3c9ea6d commit 0c7f606
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/evmone/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ evmc_result baseline_execute(ExecutionState& state, const JumpdestMap& jumpdest_
sar(state.stack);
break;

case OP_SHA3:
case OP_KECCAK256:
{
const auto status_code = sha3(state);
const auto status_code = keccak256(state);
if (status_code != EVMC_SUCCESS)
{
state.status = status_code;
Expand Down
4 changes: 2 additions & 2 deletions lib/evmone/instruction_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ constexpr inline std::array<Traits, 256> traits = []() noexcept {
table[OP_SHR] = {"SHR", 2, -1};
table[OP_SAR] = {"SAR", 2, -1};

table[OP_SHA3] = {"SHA3", 2, -1};
table[OP_KECCAK256] = {"KECCAK256", 2, -1};

table[OP_ADDRESS] = {"ADDRESS", 0, 1};
table[OP_BALANCE] = {"BALANCE", 1, 0};
Expand Down Expand Up @@ -233,7 +233,7 @@ constexpr inline std::array<int16_t, 256> gas_costs<EVMC_FRONTIER> = []() noexce
table[OP_XOR] = 3;
table[OP_NOT] = 3;
table[OP_BYTE] = 3;
table[OP_SHA3] = 30;
table[OP_KECCAK256] = 30;
table[OP_ADDRESS] = 2;
table[OP_BALANCE] = 20;
table[OP_ORIGIN] = 2;
Expand Down
2 changes: 1 addition & 1 deletion lib/evmone/instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ constexpr std::array<instruction_exec_fn, 256> instruction_implementations = [](
table[OP_SHR] = op<shr>;
table[OP_SAR] = op<sar>;

table[OP_SHA3] = op<sha3>;
table[OP_KECCAK256] = op<keccak256>;

table[OP_ADDRESS] = op<address>;
table[OP_BALANCE] = op<balance>;
Expand Down
2 changes: 1 addition & 1 deletion lib/evmone/instructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ inline void sar(evm_stack& stack) noexcept
}


inline evmc_status_code sha3(ExecutionState& state) noexcept
inline evmc_status_code keccak256(ExecutionState& state) noexcept
{
const auto index = state.stack.pop();
auto& size = state.stack.top();
Expand Down
14 changes: 7 additions & 7 deletions test/unittests/evm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ TEST_P(evm, invalid)
EXPECT_EQ(result.gas_left, 0);
}

TEST_P(evm, sha3)
TEST_P(evm, keccak256)
{
execute("6108006103ff2060005260206000f3");
EXPECT_EQ(result.status_code, EVMC_SUCCESS);
Expand All @@ -608,9 +608,9 @@ TEST_P(evm, sha3)
EXPECT_EQ(bytes(&result.output_data[0], 32), hash);
}

TEST_P(evm, sha3_empty)
TEST_P(evm, keccak256_empty)
{
auto code = push(0) + OP_DUP1 + OP_SHA3 + ret_top();
auto code = push(0) + OP_DUP1 + OP_KECCAK256 + ret_top();
execute(code);
ASSERT_EQ(result.output_size, 32);
auto keccak256_empty = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
Expand Down Expand Up @@ -820,11 +820,11 @@ TEST_P(evm, mstore8_memory_cost)
EXPECT_EQ(result.status_code, EVMC_OUT_OF_GAS);
}

TEST_P(evm, sha3_memory_cost)
TEST_P(evm, keccak256_memory_cost)
{
execute(45, sha3(0, 1));
execute(45, keccak256(0, 1));
EXPECT_EQ(result.status_code, EVMC_SUCCESS);
execute(44, sha3(0, 1));
execute(44, keccak256(0, 1));
EXPECT_EQ(result.status_code, EVMC_OUT_OF_GAS);
}

Expand Down Expand Up @@ -894,7 +894,7 @@ struct memory_access_params
};

memory_access_opcode memory_access_opcodes[] = {
{OP_SHA3, 0, 1},
{OP_KECCAK256, 0, 1},
{OP_CALLDATACOPY, 0, 2},
{OP_CODECOPY, 0, 2},
{OP_MLOAD, 0, -1},
Expand Down
4 changes: 2 additions & 2 deletions test/utils/bytecode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ inline bytecode ret(bytecode c)
return c + ret_top();
}

inline bytecode sha3(bytecode index, bytecode size)
inline bytecode keccak256(bytecode index, bytecode size)
{
return size + index + OP_SHA3;
return size + index + OP_KECCAK256;
}

inline bytecode calldataload(bytecode index)
Expand Down

0 comments on commit 0c7f606

Please sign in to comment.