diff --git a/Cargo.toml b/Cargo.toml index 3321e721..40ba445f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,19 +9,18 @@ keywords.workspace = true edition.workspace = true [workspace.dependencies] -evm = { version = "0.46.1", path = "." } -evm-core = { version = "0.46.1", path = "core", default-features = false } -evm-gasometer = { version = "0.46.1", path = "gasometer", default-features = false } -evm-runtime = { version = "0.46.1", path = "runtime", default-features = false } -primitive-types = { version = "0.12", default-features = false } +evm = { version = "0.46.2", path = "." } +evm-core = { version = "0.46.2", path = "core", default-features = false } +evm-gasometer = { version = "0.46.2", path = "gasometer", default-features = false } +evm-runtime = { version = "0.46.2", path = "runtime", default-features = false } +primitive-types = { version = "0.13", default-features = false } auto_impl = "1.0" sha3 = { version = "0.10", default-features = false } [dependencies] -ethereum = { version = "0.15", default-features = false } log = { version = "0.4", default-features = false } primitive-types = { workspace = true, features = ["rlp"] } -rlp = { version = "0.5", default-features = false } +rlp = { version = "0.6", default-features = false, features = ["derive"] } smallvec = "1.13" # Optional dependencies @@ -47,7 +46,6 @@ harness = false [features] default = ["std", "force-debug"] std = [ - "ethereum/std", "log/std", "primitive-types/std", "rlp/std", @@ -65,14 +63,12 @@ with-codec = [ "scale-info", "primitive-types/codec", "primitive-types/scale-info", - "ethereum/with-codec", "evm-core/with-codec", ] with-serde = [ "serde", "primitive-types/impl-serde", "evm-core/with-serde", - "ethereum/with-serde", ] tracing = [ "environmental", @@ -88,7 +84,7 @@ create-fixed = [] print-debug = ["evm-gasometer/print-debug"] [workspace.package] -version = "0.46.1" +version = "0.46.2" license = "Apache-2.0" authors = ["Aurora Labs ", "Wei Tang ", "Parity Technologies "] description = "Portable Ethereum Virtual Machine implementation written in pure Rust." diff --git a/core/src/eval/macros.rs b/core/src/eval/macros.rs index f26f9f53..300ead22 100644 --- a/core/src/eval/macros.rs +++ b/core/src/eval/macros.rs @@ -21,11 +21,7 @@ macro_rules! pop_h256 { ( $machine:expr, $( $x:ident ),* ) => ( $( let $x = match $machine.stack.pop() { - Ok(value) => { - let mut res = H256([0; 32]); - value.to_big_endian(&mut res[..]); - res - }, + Ok(value) => H256(value.to_big_endian()), Err(e) => return Control::Exit(e.into()), }; )* diff --git a/core/src/stack.rs b/core/src/stack.rs index fc73f84d..083fc540 100644 --- a/core/src/stack.rs +++ b/core/src/stack.rs @@ -62,11 +62,7 @@ impl Stack { /// Return `ExitError` #[inline] pub fn pop_h256(&mut self) -> Result { - self.pop().map(|it| { - let mut res = H256([0; 32]); - it.to_big_endian(&mut res.0); - res - }) + self.pop().map(|it| H256(it.to_big_endian())) } /// Push a new value into the stack. If it will exceed the stack limit, @@ -106,11 +102,7 @@ impl Stack { /// # Errors /// Return `ExitError` pub fn peek_h256(&self, no_from_top: usize) -> Result { - self.peek(no_from_top).map(|it| { - let mut res = H256([0; 32]); - it.to_big_endian(&mut res.0); - res - }) + self.peek(no_from_top).map(|it| H256(it.to_big_endian())) } /// Peek a value at given index for the stack as usize. diff --git a/evm-tests/EIP-152/src/lib.rs b/evm-tests/EIP-152/src/lib.rs index bc7d317d..79830c1b 100644 --- a/evm-tests/EIP-152/src/lib.rs +++ b/evm-tests/EIP-152/src/lib.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Open Ethereum. If not, see . +#![allow(clippy::too_long_first_doc_paragraph)] + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub mod avx2; pub mod portable; diff --git a/evm-tests/ethcore-builtin/Cargo.toml b/evm-tests/ethcore-builtin/Cargo.toml index adfd4ec5..0e573b61 100644 --- a/evm-tests/ethcore-builtin/Cargo.toml +++ b/evm-tests/ethcore-builtin/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" bn = { git = "https://github.com/paritytech/bn", rev = "b048fe1", default-features = false } byteorder = "1.3.2" eip-152 = { path = "../EIP-152" } -ethereum-types = "0.14" +ethereum-types = "0.15" ethjson = { path = "../ethjson" } keccak-hash = "0.10" log = "0.4" diff --git a/evm-tests/ethcore-builtin/src/lib.rs b/evm-tests/ethcore-builtin/src/lib.rs index 1eee216e..388806cf 100644 --- a/evm-tests/ethcore-builtin/src/lib.rs +++ b/evm-tests/ethcore-builtin/src/lib.rs @@ -1159,8 +1159,7 @@ impl Bn128Pairing { } }; - let mut buf = [0u8; 32]; - ret_val.to_big_endian(&mut buf); + let buf = ret_val.to_big_endian(); output.write(0, &buf); Ok(()) diff --git a/evm-tests/ethjson/Cargo.toml b/evm-tests/ethjson/Cargo.toml index 50f0ab90..5e0cf0ea 100644 --- a/evm-tests/ethjson/Cargo.toml +++ b/evm-tests/ethjson/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -ethereum-types = "0.14" +ethereum-types = "0.15" rustc-hex = "2.1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/evm-tests/ethjson/src/lib.rs b/evm-tests/ethjson/src/lib.rs index 17a9581c..7ac15ad7 100644 --- a/evm-tests/ethjson/src/lib.rs +++ b/evm-tests/ethjson/src/lib.rs @@ -17,6 +17,7 @@ //! JSON deserialization library #![warn(missing_docs)] +#![allow(clippy::too_long_first_doc_paragraph)] pub mod bytes; pub mod hash; diff --git a/evm-tests/jsontests/Cargo.toml b/evm-tests/jsontests/Cargo.toml index 77327993..9c2b7ebf 100644 --- a/evm-tests/jsontests/Cargo.toml +++ b/evm-tests/jsontests/Cargo.toml @@ -11,7 +11,7 @@ edition.workspace = true [dependencies] evm.workspace = true ethereum = "0.15.0" -primitive-types = "0.12" +primitive-types = "0.13" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" hex = "0.4" @@ -19,11 +19,11 @@ clap = { version = "4.5", features = ["cargo"] } ethjson = { path = "../ethjson", features = ["test-helpers"] } libsecp256k1 = "0.7" ethcore-builtin = { path = "../ethcore-builtin" } -rlp = "0.5" +rlp = "0.6" sha3 = "0.10" parity-bytes = "0.1" env_logger = "0.11" -lazy_static = "1.4.0" +lazy_static = "1.5" [features] enable-slow-tests = [] diff --git a/evm-tests/jsontests/src/state.rs b/evm-tests/jsontests/src/state.rs index 7fa8c436..48b30775 100644 --- a/evm-tests/jsontests/src/state.rs +++ b/evm-tests/jsontests/src/state.rs @@ -1288,8 +1288,6 @@ fn test_run( ); for (addr, acc) in backend.state().clone() { // Decode balance - let mut write_buf = [0u8; 32]; - acc.balance.to_big_endian(&mut write_buf[..]); let balance = acc.balance.to_string(); println!( diff --git a/evm-tests/jsontests/src/utils.rs b/evm-tests/jsontests/src/utils.rs index d2539cda..6d3f2b8c 100644 --- a/evm-tests/jsontests/src/utils.rs +++ b/evm-tests/jsontests/src/utils.rs @@ -4,9 +4,7 @@ use sha3::{Digest, Keccak256}; use std::collections::BTreeMap; pub fn u256_to_h256(u: U256) -> H256 { - let mut h = H256::default(); - u.to_big_endian(&mut h[..]); - h + H256(u.to_big_endian()) } pub fn unwrap_to_account(s: ðjson::spec::Account) -> MemoryAccount { @@ -106,11 +104,14 @@ pub fn check_valid_hash(h: &H256, b: &BTreeMap) -> (bool, H let tree = b .iter() .map(|(address, account)| { - let storage_root = ethereum::util::sec_trie_root( - account - .storage - .iter() - .map(|(k, v)| (k, rlp::encode(&U256::from_big_endian(&v[..])))), + let storage_root = H256( + ethereum::util::sec_trie_root( + account + .storage + .iter() + .map(|(k, v)| (k, rlp::encode(&U256::from_big_endian(&v[..])))), + ) + .0, ); let code_hash = H256::from_slice(Keccak256::digest(&account.code).as_slice()); @@ -126,7 +127,7 @@ pub fn check_valid_hash(h: &H256, b: &BTreeMap) -> (bool, H }) .collect::>(); - let root = ethereum::util::sec_trie_root(tree); + let root = H256(ethereum::util::sec_trie_root(tree).0); let expect = h; (root == *expect, root) } @@ -321,8 +322,7 @@ pub mod transaction { // all versioned blob hashes must start with VERSIONED_HASH_VERSION_KZG for blob in test_tx.blob_versioned_hashes.iter() { - let mut blob_hash = H256([0; 32]); - blob.to_big_endian(&mut blob_hash[..]); + let blob_hash = H256(blob.to_big_endian()); if blob_hash[0] != super::eip_4844::VERSIONED_HASH_VERSION_KZG { return Err(InvalidTxReason::BlobVersionNotSupported); } diff --git a/evm-tests/jsontests/src/vm.rs b/evm-tests/jsontests/src/vm.rs index 8a0f9651..3ab2df16 100644 --- a/evm-tests/jsontests/src/vm.rs +++ b/evm-tests/jsontests/src/vm.rs @@ -24,9 +24,7 @@ impl Test { // (0x44), and so for older forks of Ethereum, the threshold value of 2^64 is used to // distinguish between the two: if it's below, the value corresponds to the DIFFICULTY // opcode, otherwise to the PREVRANDAO opcode. - let mut buf = [0u8; 32]; - r.0.to_big_endian(&mut buf); - H256(buf) + H256(r.0.to_big_endian()) }); MemoryVicinity { diff --git a/runtime/src/eval/macros.rs b/runtime/src/eval/macros.rs index 4be9b53b..058e922c 100644 --- a/runtime/src/eval/macros.rs +++ b/runtime/src/eval/macros.rs @@ -11,11 +11,7 @@ macro_rules! pop_h256 { ( $machine:expr, $( $x:ident ),* ) => ( $( let $x = match $machine.machine.stack_mut().pop() { - Ok(value) => { - let mut res = H256([0; 32]); - value.to_big_endian(&mut res[..]); - res - }, + Ok(value) => H256(value.to_big_endian()), Err(e) => return Control::Exit(e.into()), }; )* diff --git a/runtime/src/eval/system.rs b/runtime/src/eval/system.rs index 7d942391..593da35d 100644 --- a/runtime/src/eval/system.rs +++ b/runtime/src/eval/system.rs @@ -73,16 +73,14 @@ pub fn caller(runtime: &mut Runtime) -> Control { } pub fn callvalue(runtime: &mut Runtime) -> Control { - let mut ret = H256::default(); - runtime.context.apparent_value.to_big_endian(&mut ret[..]); + let ret = H256(runtime.context.apparent_value.to_big_endian()); push_h256!(runtime, ret); Control::Continue } pub fn gasprice(runtime: &mut Runtime, handler: &H) -> Control { - let mut ret = H256::default(); - handler.gas_price().to_big_endian(&mut ret[..]); + let ret = H256(handler.gas_price().to_big_endian()); push_h256!(runtime, ret); Control::Continue @@ -294,11 +292,7 @@ pub fn sstore(runtime: &mut Runtime, handler: &mut H) -> Control pub fn tload(runtime: &mut Runtime, handler: &mut H) -> Control { // Peek index from the top of the stack let index = match runtime.machine.stack().peek(0) { - Ok(value) => { - let mut h = H256::default(); - value.to_big_endian(&mut h[..]); - h - } + Ok(value) => H256(value.to_big_endian()), Err(e) => return Control::Exit(e.into()), }; // Load value from transient storage diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0f102b72..812fd681 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.81.0" +channel = "1.82.0" profile = "minimal" components = ["rustfmt", "clippy"] diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 935d0564..8e8a508d 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -22,7 +22,17 @@ pub struct Basic { pub nonce: U256, } -pub use ethereum::Log; +#[derive(Clone, Debug, PartialEq, Eq, Default, rlp::RlpEncodable, rlp::RlpDecodable)] +#[cfg_attr( + feature = "with-codec", + derive(scale_codec::Encode, scale_codec::Decode, scale_info::TypeInfo) +)] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Log { + pub address: H160, + pub topics: Vec, + pub data: Vec, +} /// Apply state operation. #[derive(Clone, Debug)] diff --git a/src/executor/stack/mod.rs b/src/executor/stack/mod.rs index 9908f24e..2791ead4 100644 --- a/src/executor/stack/mod.rs +++ b/src/executor/stack/mod.rs @@ -14,4 +14,3 @@ pub use self::memory::{MemoryStackAccount, MemoryStackState, MemoryStackSubstate pub use self::precompile::{ PrecompileFailure, PrecompileFn, PrecompileHandle, PrecompileOutput, PrecompileSet, }; -pub use ethereum::Log; diff --git a/src/maybe_borrowed.rs b/src/maybe_borrowed.rs index a7483bb7..c5dcc686 100644 --- a/src/maybe_borrowed.rs +++ b/src/maybe_borrowed.rs @@ -1,6 +1,7 @@ //! A module containing the `MaybeBorrowed` enum. See its documentation for details. /// Similar to `Cow` from the standard library, but without requiring `T: Clone`. +/// /// Instead of "copy on write", this data structure represents a type that can create /// `&mut T`, either because it is `&mut T`, or because it is an owned `T`. /// This is also distinct from the `BorrowMut` trait in the standard library because