From 5833ef988677e092f104c171e8abc644df401d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 26 Apr 2021 14:32:58 +0200 Subject: [PATCH] Rename sha3() instruction to keccak256() --- lib/evmone/baseline.cpp | 2 +- lib/evmone/instructions.cpp | 2 +- lib/evmone/instructions.hpp | 2 +- test/unittests/evm_test.cpp | 10 +++++----- test/utils/bytecode.hpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/evmone/baseline.cpp b/lib/evmone/baseline.cpp index 5a6f60fe11..431e4da0e9 100644 --- a/lib/evmone/baseline.cpp +++ b/lib/evmone/baseline.cpp @@ -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; diff --git a/lib/evmone/instructions.cpp b/lib/evmone/instructions.cpp index d61a06b250..06ab6f8b96 100644 --- a/lib/evmone/instructions.cpp +++ b/lib/evmone/instructions.cpp @@ -227,7 +227,7 @@ constexpr std::array instruction_implementations = []( table[OP_SHR] = op; table[OP_SAR] = op; - table[OP_KECCAK256] = op; + table[OP_KECCAK256] = op; table[OP_ADDRESS] = op
; table[OP_BALANCE] = op; diff --git a/lib/evmone/instructions.hpp b/lib/evmone/instructions.hpp index f3d109255f..3372d22382 100644 --- a/lib/evmone/instructions.hpp +++ b/lib/evmone/instructions.hpp @@ -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(); diff --git a/test/unittests/evm_test.cpp b/test/unittests/evm_test.cpp index 28aa430500..a002cd61c1 100644 --- a/test/unittests/evm_test.cpp +++ b/test/unittests/evm_test.cpp @@ -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); @@ -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); @@ -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); } diff --git a/test/utils/bytecode.hpp b/test/utils/bytecode.hpp index 7f20cd8aef..d92528ee71 100644 --- a/test/utils/bytecode.hpp +++ b/test/utils/bytecode.hpp @@ -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; }