Skip to content

Commit

Permalink
Rename sha3() instruction to keccak256()
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Apr 27, 2021
1 parent c6a8724 commit 5833ef9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/evmone/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ evmc_result baseline_execute(ExecutionState& state, const JumpdestMap& jumpdest_

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
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_KECCAK256] = 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
10 changes: 5 additions & 5 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,7 +608,7 @@ 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_KECCAK256 + ret_top();
execute(code);
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
2 changes: 1 addition & 1 deletion test/utils/bytecode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ 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_KECCAK256;
}
Expand Down

0 comments on commit 5833ef9

Please sign in to comment.