From 56ce3313f58ebccd6491d9f71716cfb7780b74c2 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Thu, 15 Aug 2024 16:12:31 +0200 Subject: [PATCH] fix: review --- Cargo.lock | 3 +++ common/Cargo.toml | 5 +++++ common/src/lib.rs | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 654337a7c..33b8be650 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5889,7 +5889,10 @@ dependencies = [ name = "zk_evm_common" version = "0.1.0" dependencies = [ + "bytes", "ethereum-types", + "keccak-hash 0.10.0", + "rlp", ] [[package]] diff --git a/common/Cargo.toml b/common/Cargo.toml index 361d92cb7..c11038439 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -10,3 +10,8 @@ categories.workspace = true [dependencies] ethereum-types = { workspace = true } +keccak-hash = { workspace = true } + +[dev-dependencies] +bytes = { workspace = true } +rlp = { workspace = true } diff --git a/common/src/lib.rs b/common/src/lib.rs index 639971c67..6f4458c8a 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,15 +1,28 @@ use ethereum_types::H256; -/// Empty code hash value +/// Hash value of account empty EVM code. /// 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 pub const EMPTY_CODE_HASH: H256 = H256([ 197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125, 178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112, ]); -/// The hash of an empty trie. +/// The hash of an empty Merkle Patricia trie. /// 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 pub const EMPTY_TRIE_HASH: H256 = H256([ 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, ]); + +#[test] +fn test_code_hash() { + assert_eq!(EMPTY_CODE_HASH, keccak_hash::keccak([])); +} + +#[test] +fn test_empty_trie_hash() { + assert_eq!( + EMPTY_TRIE_HASH, + keccak_hash::keccak(bytes::Bytes::from_static(&rlp::NULL_RLP)) + ); +}