From 2ba8647533007ccbc065cc08b52a9db4f24dd339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 26 Apr 2021 13:10:58 +0200 Subject: [PATCH] Rename instruction SHA3 -> KECCAK256 As proposed by EIP-1803 https://eips.ethereum.org/EIPS/eip-1803 and already done in many other projects, including solidity and ethereum-js. --- CHANGELOG.md | 6 ++++++ include/evmc/instructions.h | 2 +- lib/instructions/instruction_metrics.c | 14 +++++++------- lib/instructions/instruction_names.c | 10 +++++----- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 578888e4d..e78d6d916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning]. `access_account()` and `access_storage()` functions added to `evmc_host_interface`. [#571](https://github.com/ethereum/evmc/pull/571) +### Changed + +- Instruction `SHA3` has been renamed to `KECCAK256` as proposed by + [EIP-1803](https://eips.ethereum.org/EIPS/eip-1803) to better match the underlying hash function. + [#590](https://github.com/ethereum/evmc/pull/590) + ## [7.5.0] — 2021-03-23 ### Added diff --git a/include/evmc/instructions.h b/include/evmc/instructions.h index 1bfcd9ef4..e9e034c60 100644 --- a/include/evmc/instructions.h +++ b/include/evmc/instructions.h @@ -53,7 +53,7 @@ enum evmc_opcode OP_SHR = 0x1c, OP_SAR = 0x1d, - OP_SHA3 = 0x20, + OP_KECCAK256 = 0x20, OP_ADDRESS = 0x30, OP_BALANCE = 0x31, diff --git a/lib/instructions/instruction_metrics.c b/lib/instructions/instruction_metrics.c index 9bdd029dc..c6d3786eb 100644 --- a/lib/instructions/instruction_metrics.c +++ b/lib/instructions/instruction_metrics.c @@ -64,7 +64,7 @@ static struct evmc_instruction_metrics berlin_metrics[256] = { /* SAR = 0x1d */ {VERYLOW, 2, -1}, /* = 0x1e */ {UNDEFINED, 0, 0}, /* = 0x1f */ {UNDEFINED, 0, 0}, - /* SHA3 = 0x20 */ {30, 2, -1}, + /* KECCAK256 = 0x20 */ {30, 2, -1}, /* = 0x21 */ {UNDEFINED, 0, 0}, /* = 0x22 */ {UNDEFINED, 0, 0}, /* = 0x23 */ {UNDEFINED, 0, 0}, @@ -323,7 +323,7 @@ static struct evmc_instruction_metrics istanbul_metrics[256] = { /* SAR = 0x1d */ {VERYLOW, 2, -1}, /* = 0x1e */ {UNDEFINED, 0, 0}, /* = 0x1f */ {UNDEFINED, 0, 0}, - /* SHA3 = 0x20 */ {30, 2, -1}, + /* KECCAK256 = 0x20 */ {30, 2, -1}, /* = 0x21 */ {UNDEFINED, 0, 0}, /* = 0x22 */ {UNDEFINED, 0, 0}, /* = 0x23 */ {UNDEFINED, 0, 0}, @@ -582,7 +582,7 @@ static struct evmc_instruction_metrics constantinople_metrics[256] = { /* SAR = 0x1d */ {VERYLOW, 2, -1}, /* = 0x1e */ {UNDEFINED, 0, 0}, /* = 0x1f */ {UNDEFINED, 0, 0}, - /* SHA3 = 0x20 */ {30, 2, -1}, + /* KECCAK256 = 0x20 */ {30, 2, -1}, /* = 0x21 */ {UNDEFINED, 0, 0}, /* = 0x22 */ {UNDEFINED, 0, 0}, /* = 0x23 */ {UNDEFINED, 0, 0}, @@ -841,7 +841,7 @@ static struct evmc_instruction_metrics byzantium_metrics[256] = { /* = 0x1d */ {UNDEFINED, 0, 0}, /* = 0x1e */ {UNDEFINED, 0, 0}, /* = 0x1f */ {UNDEFINED, 0, 0}, - /* SHA3 = 0x20 */ {30, 2, -1}, + /* KECCAK256 = 0x20 */ {30, 2, -1}, /* = 0x21 */ {UNDEFINED, 0, 0}, /* = 0x22 */ {UNDEFINED, 0, 0}, /* = 0x23 */ {UNDEFINED, 0, 0}, @@ -1100,7 +1100,7 @@ static struct evmc_instruction_metrics tangerine_whistle_metrics[256] = { /* = 0x1d */ {UNDEFINED, 0, 0}, /* = 0x1e */ {UNDEFINED, 0, 0}, /* = 0x1f */ {UNDEFINED, 0, 0}, - /* SHA3 = 0x20 */ {30, 2, -1}, + /* KECCAK256 = 0x20 */ {30, 2, -1}, /* = 0x21 */ {UNDEFINED, 0, 0}, /* = 0x22 */ {UNDEFINED, 0, 0}, /* = 0x23 */ {UNDEFINED, 0, 0}, @@ -1359,7 +1359,7 @@ static struct evmc_instruction_metrics homestead_metrics[256] = { /* = 0x1d */ {UNDEFINED, 0, 0}, /* = 0x1e */ {UNDEFINED, 0, 0}, /* = 0x1f */ {UNDEFINED, 0, 0}, - /* SHA3 = 0x20 */ {30, 2, -1}, + /* KECCAK256 = 0x20 */ {30, 2, -1}, /* = 0x21 */ {UNDEFINED, 0, 0}, /* = 0x22 */ {UNDEFINED, 0, 0}, /* = 0x23 */ {UNDEFINED, 0, 0}, @@ -1618,7 +1618,7 @@ static struct evmc_instruction_metrics frontier_metrics[256] = { /* = 0x1d */ {UNDEFINED, 0, 0}, /* = 0x1e */ {UNDEFINED, 0, 0}, /* = 0x1f */ {UNDEFINED, 0, 0}, - /* SHA3 = 0x20 */ {30, 2, -1}, + /* KECCAK256 = 0x20 */ {30, 2, -1}, /* = 0x21 */ {UNDEFINED, 0, 0}, /* = 0x22 */ {UNDEFINED, 0, 0}, /* = 0x23 */ {UNDEFINED, 0, 0}, diff --git a/lib/instructions/instruction_names.c b/lib/instructions/instruction_names.c index 9bf877676..afecd39ac 100644 --- a/lib/instructions/instruction_names.c +++ b/lib/instructions/instruction_names.c @@ -38,7 +38,7 @@ static const char* istanbul_names[256] = { /* 0x1d */ "SAR", /* 0x1e */ NULL, /* 0x1f */ NULL, - /* 0x20 */ "SHA3", + /* 0x20 */ "KECCAK256", /* 0x21 */ NULL, /* 0x22 */ NULL, /* 0x23 */ NULL, @@ -297,7 +297,7 @@ static const char* constantinople_names[256] = { /* 0x1d */ "SAR", /* 0x1e */ NULL, /* 0x1f */ NULL, - /* 0x20 */ "SHA3", + /* 0x20 */ "KECCAK256", /* 0x21 */ NULL, /* 0x22 */ NULL, /* 0x23 */ NULL, @@ -556,7 +556,7 @@ static const char* byzantium_names[256] = { /* 0x1d */ NULL, /* 0x1e */ NULL, /* 0x1f */ NULL, - /* 0x20 */ "SHA3", + /* 0x20 */ "KECCAK256", /* 0x21 */ NULL, /* 0x22 */ NULL, /* 0x23 */ NULL, @@ -815,7 +815,7 @@ static const char* homestead_names[256] = { /* 0x1d */ NULL, /* 0x1e */ NULL, /* 0x1f */ NULL, - /* 0x20 */ "SHA3", + /* 0x20 */ "KECCAK256", /* 0x21 */ NULL, /* 0x22 */ NULL, /* 0x23 */ NULL, @@ -1074,7 +1074,7 @@ static const char* frontier_names[256] = { /* 0x1d */ NULL, /* 0x1e */ NULL, /* 0x1f */ NULL, - /* 0x20 */ "SHA3", + /* 0x20 */ "KECCAK256", /* 0x21 */ NULL, /* 0x22 */ NULL, /* 0x23 */ NULL,