From 886749515fea7a3d819af3b1e05621fd23ee5ea8 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:26:01 +0000 Subject: [PATCH 1/9] feat: Rename all SHA3 opcodes to KECCAK256 --- crates/interpreter/src/instructions/opcode.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/interpreter/src/instructions/opcode.rs b/crates/interpreter/src/instructions/opcode.rs index 2d747249ad..543f762e04 100644 --- a/crates/interpreter/src/instructions/opcode.rs +++ b/crates/interpreter/src/instructions/opcode.rs @@ -38,7 +38,7 @@ pub const CODECOPY: u8 = 0x39; pub const SHL: u8 = 0x1b; pub const SHR: u8 = 0x1c; pub const SAR: u8 = 0x1d; -pub const SHA3: u8 = 0x20; +pub const KECCAK256: u8 = 0x20; pub const POP: u8 = 0x50; pub const MLOAD: u8 = 0x51; pub const MSTORE: u8 = 0x52; @@ -550,7 +550,7 @@ macro_rules! gas_opcodee { }), /* 0x1e */ OpInfo::none(), /* 0x1f */ OpInfo::none(), - /* 0x20 SHA3 */ OpInfo::dynamic_gas(), + /* 0x20 KECCAK256 */ OpInfo::dynamic_gas(), /* 0x21 */ OpInfo::none(), /* 0x22 */ OpInfo::none(), /* 0x23 */ OpInfo::none(), From cb8c4824bf1487878f4f67bdde692bc092d07787 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Sat, 10 Jun 2023 03:13:26 +0000 Subject: [PATCH 2/9] feat: renaming sha3 function --- Cargo.lock | 14 +++++++------- bins/revme/Cargo.toml | 2 +- bins/revme/src/statetest/merkle_trie.rs | 2 +- crates/interpreter/Cargo.toml | 4 ++-- crates/interpreter/src/gas/calc.rs | 2 +- crates/interpreter/src/instructions.rs | 2 +- crates/interpreter/src/instructions/system.rs | 4 ++-- crates/precompile/Cargo.toml | 2 +- crates/precompile/src/secp256k1.rs | 4 ++-- crates/primitives/Cargo.toml | 4 ++-- crates/primitives/src/utilities.rs | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 417733ae61..a99741f5c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,7 +411,7 @@ dependencies = [ "rand", "rlp", "serde", - "sha3", + "keccak256", "zeroize", ] @@ -459,7 +459,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha3", + "keccak256", "thiserror", "uint", ] @@ -1688,7 +1688,7 @@ dependencies = [ "proptest-derive", "revm-primitives", "serde", - "sha3", + "keccak256", ] [[package]] @@ -1703,7 +1703,7 @@ dependencies = [ "ripemd", "secp256k1", "sha2", - "sha3", + "keccak256", "substrate-bn", ] @@ -1728,7 +1728,7 @@ dependencies = [ "rlp", "ruint", "serde", - "sha3", + "keccak256", ] [[package]] @@ -1758,7 +1758,7 @@ dependencies = [ "ruint", "serde", "serde_json", - "sha3", + "keccak256", "structopt", "thiserror", "triehash", @@ -2078,7 +2078,7 @@ dependencies = [ ] [[package]] -name = "sha3" +name = "keccak256" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54c2bb1a323307527314a36bfb73f24febb08ce2b8a554bf4ffd6f51ad15198c" diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index e9f9d07dbb..3c854d89b5 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -26,7 +26,7 @@ rlp = { version = "0.5", default-features = false } ruint = { version = "1.8.0", features = ["rlp", "serde"] } serde = { version = "1.0", features = ["derive", "rc"] } serde_json = { version = "1.0", features = ["preserve_order"] } -sha3 = { version = "0.10", default-features = false } +keccak256 = { version = "0.10", default-features = false } structopt = "0.3" thiserror = "1.0" triehash = "0.8" diff --git a/bins/revme/src/statetest/merkle_trie.rs b/bins/revme/src/statetest/merkle_trie.rs index af3328dbd3..aae99b2694 100644 --- a/bins/revme/src/statetest/merkle_trie.rs +++ b/bins/revme/src/statetest/merkle_trie.rs @@ -7,7 +7,7 @@ use revm::{ primitives::{keccak256, Log, B160, B256, U256}, }; use rlp::RlpStream; -use sha3::{Digest, Keccak256}; +use keccak256::{Digest, Keccak256}; use triehash::sec_trie_root; pub fn log_rlp_hash(logs: Vec) -> B256 { diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index a5c4fec52f..d17b917e6d 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -16,8 +16,8 @@ revm-primitives = { path = "../primitives", version="1.1.2", default-features = derive_more = "0.99" enumn = "0.1" -# sha3 keccak hasher -sha3 = { version = "0.10", default-features = false, features = [] } +# keccak256 keccak hasher +keccak256 = { version = "0.10", default-features = false, features = [] } # optional serde = { version = "1.0", features = ["derive", "rc"], optional = true } diff --git a/crates/interpreter/src/gas/calc.rs b/crates/interpreter/src/gas/calc.rs index d255cee967..72fbe044a4 100644 --- a/crates/interpreter/src/gas/calc.rs +++ b/crates/interpreter/src/gas/calc.rs @@ -146,7 +146,7 @@ pub fn log_cost(n: u8, len: u64) -> Option { .checked_add(LOGTOPIC * n as u64) } -pub fn sha3_cost(len: u64) -> Option { +pub fn keccak256_cost(len: u64) -> Option { let wordd = len / 32; let wordr = len % 32; SHA3.checked_add(SHA3WORD.checked_mul(if wordr == 0 { wordd } else { wordd + 1 })?) diff --git a/crates/interpreter/src/instructions.rs b/crates/interpreter/src/instructions.rs index 94f220930b..f0e8dfb722 100644 --- a/crates/interpreter/src/instructions.rs +++ b/crates/interpreter/src/instructions.rs @@ -55,7 +55,7 @@ pub fn eval(opcode: u8, interp: &mut Interpreter, host: &mut H opcode::SHL => bitwise::shl::(interp, host), opcode::SHR => bitwise::shr::(interp, host), opcode::SAR => bitwise::sar::(interp, host), - opcode::SHA3 => system::sha3(interp, host), + opcode::SHA3 => system::keccak256(interp, host), opcode::ADDRESS => system::address(interp, host), opcode::BALANCE => host::balance::(interp, host), opcode::SELFBALANCE => host::selfbalance::(interp, host), diff --git a/crates/interpreter/src/instructions/system.rs b/crates/interpreter/src/instructions/system.rs index bfef1465f7..9ed0c75aa1 100644 --- a/crates/interpreter/src/instructions/system.rs +++ b/crates/interpreter/src/instructions/system.rs @@ -6,10 +6,10 @@ use crate::{ }; use core::cmp::min; -pub fn sha3(interpreter: &mut Interpreter, _host: &mut dyn Host) { +pub fn keccak256(interpreter: &mut Interpreter, _host: &mut dyn Host) { pop!(interpreter, from, len); let len = as_usize_or_fail!(interpreter, len, InstructionResult::InvalidOperandOOG); - gas_or_fail!(interpreter, gas::sha3_cost(len as u64)); + gas_or_fail!(interpreter, gas::keccak256_cost(len as u64)); let hash = if len == 0 { KECCAK_EMPTY } else { diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index c137bd2935..d8013ae220 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -17,7 +17,7 @@ once_cell = "1.17" ripemd = { version = "0.1", default-features = false } secp256k1 = { version = "0.27.0", default-features = false, features = ["alloc", "recovery"], optional = true } sha2 = { version = "0.10.5", default-features = false } -sha3 = { version = "0.10.7", default-features = false } +keccak256 = { version = "0.10.7", default-features = false } [dev-dependencies] hex = "0.4" diff --git a/crates/precompile/src/secp256k1.rs b/crates/precompile/src/secp256k1.rs index 7bd44d09d6..96bbb34fcc 100644 --- a/crates/precompile/src/secp256k1.rs +++ b/crates/precompile/src/secp256k1.rs @@ -9,7 +9,7 @@ pub const ECRECOVER: PrecompileAddress = PrecompileAddress( #[allow(clippy::module_inception)] mod secp256k1 { use k256::ecdsa::{Error, RecoveryId, Signature, VerifyingKey}; - use sha3::{Digest, Keccak256}; + use keccak256::{Digest, Keccak256}; use crate::B256; @@ -43,7 +43,7 @@ mod secp256k1 { ecdsa::{RecoverableSignature, RecoveryId}, Message, Secp256k1, }; - use sha3::{Digest, Keccak256}; + use keccak256::{Digest, Keccak256}; pub fn ecrecover(sig: &[u8; 65], msg: &B256) -> Result { let sig = diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index b9ba3953e8..2a329e5240 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -31,8 +31,8 @@ hex-literal = "0.4" derive_more = "0.99" enumn = "0.1" -# sha3 keccak hasher -sha3 = { version = "0.10", default-features = false, features = [] } +# keccak256 keccak hasher +keccak256 = { version = "0.10", default-features = false, features = [] } # optional serde = { version = "1.0", features = ["derive", "rc"], optional = true } diff --git a/crates/primitives/src/utilities.rs b/crates/primitives/src/utilities.rs index ff5d364c80..cbe7422bf2 100644 --- a/crates/primitives/src/utilities.rs +++ b/crates/primitives/src/utilities.rs @@ -1,6 +1,6 @@ use crate::{B160, B256, U256}; use hex_literal::hex; -use sha3::{Digest, Keccak256}; +use keccak256::{Digest, Keccak256}; pub const KECCAK_EMPTY: B256 = B256(hex!( "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" From 20fec4e9247e9d2ec08e08fe8a283101827c5a31 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Sat, 10 Jun 2023 03:14:17 +0000 Subject: [PATCH 3/9] feat: renaming sha3 params --- crates/interpreter/src/gas/calc.rs | 4 ++-- crates/interpreter/src/gas/constants.rs | 4 ++-- crates/interpreter/src/instructions.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/interpreter/src/gas/calc.rs b/crates/interpreter/src/gas/calc.rs index 72fbe044a4..ae7d7c4b5f 100644 --- a/crates/interpreter/src/gas/calc.rs +++ b/crates/interpreter/src/gas/calc.rs @@ -62,7 +62,7 @@ pub fn create2_cost(len: usize) -> Option { // ceil(len / 32.0) let len = len as u64; let sha_addup_base = (len / 32) + u64::from((len % 32) != 0); - let sha_addup = SHA3WORD.checked_mul(sha_addup_base)?; + let sha_addup = KECCAK256WORD.checked_mul(sha_addup_base)?; let gas = base.checked_add(sha_addup)?; Some(gas) @@ -149,7 +149,7 @@ pub fn log_cost(n: u8, len: u64) -> Option { pub fn keccak256_cost(len: u64) -> Option { let wordd = len / 32; let wordr = len % 32; - SHA3.checked_add(SHA3WORD.checked_mul(if wordr == 0 { wordd } else { wordd + 1 })?) + KECCAK256.checked_add(KECCAK256WORD.checked_mul(if wordr == 0 { wordd } else { wordd + 1 })?) } /// EIP-3860: Limit and meter initcode diff --git a/crates/interpreter/src/gas/constants.rs b/crates/interpreter/src/gas/constants.rs index 6cca72ad22..b8bd7d0544 100644 --- a/crates/interpreter/src/gas/constants.rs +++ b/crates/interpreter/src/gas/constants.rs @@ -14,8 +14,8 @@ pub const MEMORY: u64 = 3; pub const LOG: u64 = 375; pub const LOGDATA: u64 = 8; pub const LOGTOPIC: u64 = 375; -pub const SHA3: u64 = 30; -pub const SHA3WORD: u64 = 6; +pub const KECCAK256: u64 = 30; +pub const KECCAK256WORD: u64 = 6; pub const COPY: u64 = 3; pub const BLOCKHASH: u64 = 20; pub const CODEDEPOSIT: u64 = 200; diff --git a/crates/interpreter/src/instructions.rs b/crates/interpreter/src/instructions.rs index f0e8dfb722..1f360cd04a 100644 --- a/crates/interpreter/src/instructions.rs +++ b/crates/interpreter/src/instructions.rs @@ -55,7 +55,7 @@ pub fn eval(opcode: u8, interp: &mut Interpreter, host: &mut H opcode::SHL => bitwise::shl::(interp, host), opcode::SHR => bitwise::shr::(interp, host), opcode::SAR => bitwise::sar::(interp, host), - opcode::SHA3 => system::keccak256(interp, host), + opcode::KECCAK256 => system::keccak256(interp, host), opcode::ADDRESS => system::address(interp, host), opcode::BALANCE => host::balance::(interp, host), opcode::SELFBALANCE => host::selfbalance::(interp, host), From b3a421f3bd5dc68588164574cf837f34f69760ef Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:27:19 +0000 Subject: [PATCH 4/9] revert: library --- bins/revme/Cargo.toml | 2 +- crates/interpreter/Cargo.toml | 2 +- crates/precompile/Cargo.toml | 2 +- crates/primitives/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index 3c854d89b5..2b3c1da4e1 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -26,7 +26,7 @@ rlp = { version = "0.5", default-features = false } ruint = { version = "1.8.0", features = ["rlp", "serde"] } serde = { version = "1.0", features = ["derive", "rc"] } serde_json = { version = "1.0", features = ["preserve_order"] } -keccak256 = { version = "0.10", default-features = false } +sha3= { version = "0.10", default-features = false } structopt = "0.3" thiserror = "1.0" triehash = "0.8" diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index d17b917e6d..0e6dc019d9 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -17,7 +17,7 @@ derive_more = "0.99" enumn = "0.1" # keccak256 keccak hasher -keccak256 = { version = "0.10", default-features = false, features = [] } +sha3= { version = "0.10", default-features = false, features = [] } # optional serde = { version = "1.0", features = ["derive", "rc"], optional = true } diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index d8013ae220..1903c7433f 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -17,7 +17,7 @@ once_cell = "1.17" ripemd = { version = "0.1", default-features = false } secp256k1 = { version = "0.27.0", default-features = false, features = ["alloc", "recovery"], optional = true } sha2 = { version = "0.10.5", default-features = false } -keccak256 = { version = "0.10.7", default-features = false } +sha3= { version = "0.10.7", default-features = false } [dev-dependencies] hex = "0.4" diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 2a329e5240..1ada8d0669 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -32,7 +32,7 @@ derive_more = "0.99" enumn = "0.1" # keccak256 keccak hasher -keccak256 = { version = "0.10", default-features = false, features = [] } +sha3= { version = "0.10", default-features = false, features = [] } # optional serde = { version = "1.0", features = ["derive", "rc"], optional = true } From 1a36dcba141e94e31e2f5cbfeb77af9c06f4ea67 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:28:09 +0000 Subject: [PATCH 5/9] revert: library.1 --- bins/revme/Cargo.toml | 2 +- crates/interpreter/Cargo.toml | 2 +- crates/precompile/Cargo.toml | 2 +- crates/primitives/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index 2b3c1da4e1..e9f9d07dbb 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -26,7 +26,7 @@ rlp = { version = "0.5", default-features = false } ruint = { version = "1.8.0", features = ["rlp", "serde"] } serde = { version = "1.0", features = ["derive", "rc"] } serde_json = { version = "1.0", features = ["preserve_order"] } -sha3= { version = "0.10", default-features = false } +sha3 = { version = "0.10", default-features = false } structopt = "0.3" thiserror = "1.0" triehash = "0.8" diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index 0e6dc019d9..a846244e18 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -17,7 +17,7 @@ derive_more = "0.99" enumn = "0.1" # keccak256 keccak hasher -sha3= { version = "0.10", default-features = false, features = [] } +sha3 = { version = "0.10", default-features = false, features = [] } # optional serde = { version = "1.0", features = ["derive", "rc"], optional = true } diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index 1903c7433f..c137bd2935 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -17,7 +17,7 @@ once_cell = "1.17" ripemd = { version = "0.1", default-features = false } secp256k1 = { version = "0.27.0", default-features = false, features = ["alloc", "recovery"], optional = true } sha2 = { version = "0.10.5", default-features = false } -sha3= { version = "0.10.7", default-features = false } +sha3 = { version = "0.10.7", default-features = false } [dev-dependencies] hex = "0.4" diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 1ada8d0669..b1a76f227e 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -32,7 +32,7 @@ derive_more = "0.99" enumn = "0.1" # keccak256 keccak hasher -sha3= { version = "0.10", default-features = false, features = [] } +sha3 = { version = "0.10", default-features = false, features = [] } # optional serde = { version = "1.0", features = ["derive", "rc"], optional = true } From bdedc32329be72a18d2873e179148b377842a799 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:29:31 +0000 Subject: [PATCH 6/9] revert: library.2 --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a99741f5c7..417733ae61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,7 +411,7 @@ dependencies = [ "rand", "rlp", "serde", - "keccak256", + "sha3", "zeroize", ] @@ -459,7 +459,7 @@ dependencies = [ "regex", "serde", "serde_json", - "keccak256", + "sha3", "thiserror", "uint", ] @@ -1688,7 +1688,7 @@ dependencies = [ "proptest-derive", "revm-primitives", "serde", - "keccak256", + "sha3", ] [[package]] @@ -1703,7 +1703,7 @@ dependencies = [ "ripemd", "secp256k1", "sha2", - "keccak256", + "sha3", "substrate-bn", ] @@ -1728,7 +1728,7 @@ dependencies = [ "rlp", "ruint", "serde", - "keccak256", + "sha3", ] [[package]] @@ -1758,7 +1758,7 @@ dependencies = [ "ruint", "serde", "serde_json", - "keccak256", + "sha3", "structopt", "thiserror", "triehash", @@ -2078,7 +2078,7 @@ dependencies = [ ] [[package]] -name = "keccak256" +name = "sha3" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54c2bb1a323307527314a36bfb73f24febb08ce2b8a554bf4ffd6f51ad15198c" From 51748170867a2e6ce12a2eb1d639bd15e4eb134f Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:30:25 +0000 Subject: [PATCH 7/9] revert: library.3 --- crates/interpreter/Cargo.toml | 2 +- crates/primitives/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index a846244e18..a5c4fec52f 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -16,7 +16,7 @@ revm-primitives = { path = "../primitives", version="1.1.2", default-features = derive_more = "0.99" enumn = "0.1" -# keccak256 keccak hasher +# sha3 keccak hasher sha3 = { version = "0.10", default-features = false, features = [] } # optional diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index b1a76f227e..b9ba3953e8 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -31,7 +31,7 @@ hex-literal = "0.4" derive_more = "0.99" enumn = "0.1" -# keccak256 keccak hasher +# sha3 keccak hasher sha3 = { version = "0.10", default-features = false, features = [] } # optional From 87d44b392927d71cdf578e7dea84d9727792d62f Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:32:05 +0000 Subject: [PATCH 8/9] revert: library.4 --- bins/revme/src/statetest/merkle_trie.rs | 2 +- crates/precompile/src/secp256k1.rs | 4 ++-- crates/primitives/src/utilities.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bins/revme/src/statetest/merkle_trie.rs b/bins/revme/src/statetest/merkle_trie.rs index aae99b2694..af3328dbd3 100644 --- a/bins/revme/src/statetest/merkle_trie.rs +++ b/bins/revme/src/statetest/merkle_trie.rs @@ -7,7 +7,7 @@ use revm::{ primitives::{keccak256, Log, B160, B256, U256}, }; use rlp::RlpStream; -use keccak256::{Digest, Keccak256}; +use sha3::{Digest, Keccak256}; use triehash::sec_trie_root; pub fn log_rlp_hash(logs: Vec) -> B256 { diff --git a/crates/precompile/src/secp256k1.rs b/crates/precompile/src/secp256k1.rs index 96bbb34fcc..7bd44d09d6 100644 --- a/crates/precompile/src/secp256k1.rs +++ b/crates/precompile/src/secp256k1.rs @@ -9,7 +9,7 @@ pub const ECRECOVER: PrecompileAddress = PrecompileAddress( #[allow(clippy::module_inception)] mod secp256k1 { use k256::ecdsa::{Error, RecoveryId, Signature, VerifyingKey}; - use keccak256::{Digest, Keccak256}; + use sha3::{Digest, Keccak256}; use crate::B256; @@ -43,7 +43,7 @@ mod secp256k1 { ecdsa::{RecoverableSignature, RecoveryId}, Message, Secp256k1, }; - use keccak256::{Digest, Keccak256}; + use sha3::{Digest, Keccak256}; pub fn ecrecover(sig: &[u8; 65], msg: &B256) -> Result { let sig = diff --git a/crates/primitives/src/utilities.rs b/crates/primitives/src/utilities.rs index cbe7422bf2..ff5d364c80 100644 --- a/crates/primitives/src/utilities.rs +++ b/crates/primitives/src/utilities.rs @@ -1,6 +1,6 @@ use crate::{B160, B256, U256}; use hex_literal::hex; -use keccak256::{Digest, Keccak256}; +use sha3::{Digest, Keccak256}; pub const KECCAK_EMPTY: B256 = B256(hex!( "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" From 3f7ed756b8ee0c55126d85a47fab58e3bdeefa0d Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Sat, 24 Jun 2023 13:01:04 +0700 Subject: [PATCH 9/9] fix: failing test cases --- crates/interpreter/src/instructions.rs | 2 +- crates/interpreter/src/instructions/system.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/interpreter/src/instructions.rs b/crates/interpreter/src/instructions.rs index 1f360cd04a..1fa65151d6 100644 --- a/crates/interpreter/src/instructions.rs +++ b/crates/interpreter/src/instructions.rs @@ -55,7 +55,7 @@ pub fn eval(opcode: u8, interp: &mut Interpreter, host: &mut H opcode::SHL => bitwise::shl::(interp, host), opcode::SHR => bitwise::shr::(interp, host), opcode::SAR => bitwise::sar::(interp, host), - opcode::KECCAK256 => system::keccak256(interp, host), + opcode::KECCAK256 => system::calculate_keccak256(interp, host), opcode::ADDRESS => system::address(interp, host), opcode::BALANCE => host::balance::(interp, host), opcode::SELFBALANCE => host::selfbalance::(interp, host), diff --git a/crates/interpreter/src/instructions/system.rs b/crates/interpreter/src/instructions/system.rs index 9ed0c75aa1..a40a6c6cf5 100644 --- a/crates/interpreter/src/instructions/system.rs +++ b/crates/interpreter/src/instructions/system.rs @@ -6,7 +6,7 @@ use crate::{ }; use core::cmp::min; -pub fn keccak256(interpreter: &mut Interpreter, _host: &mut dyn Host) { +pub fn calculate_keccak256(interpreter: &mut Interpreter, _host: &mut dyn Host) { pop!(interpreter, from, len); let len = as_usize_or_fail!(interpreter, len, InstructionResult::InvalidOperandOOG); gas_or_fail!(interpreter, gas::keccak256_cost(len as u64));