diff --git a/Cargo.lock b/Cargo.lock index e6b03493ca..ae802d0394 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2215,7 +2215,6 @@ dependencies = [ "futures", "hex", "hex-literal", - "once_cell", "rayon", "revm-interpreter", "revm-precompile", @@ -2276,7 +2275,6 @@ dependencies = [ "ruint", "serde", "sha3", - "to-binary", ] [[package]] @@ -2995,15 +2993,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "to-binary" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424552bc848fd1afbcd81f0e8a54b7401b90fd81bb418655ad6dc6d0823bbe3" -dependencies = [ - "hex", -] - [[package]] name = "tokio" version = "1.32.0" diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index c137bd2935..3224f1b6d1 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -9,13 +9,16 @@ repository = "https://github.com/bluealloy/revm" version = "2.0.3" [dependencies] -revm-primitives = { path = "../primitives", version="1.1.2", default-features = false } +revm-primitives = { path = "../primitives", version = "1.1.2", default-features = false } bn = { package = "substrate-bn", version = "0.6", default-features = false } k256 = { version = "0.13", default-features = false, features = ["ecdsa"] } num = { version = "0.4.0", default-features = false, features = ["alloc"] } -once_cell = "1.17" +once_cell = { version = "1.17", default-features = false, features = ["alloc"] } ripemd = { version = "0.1", default-features = false } -secp256k1 = { version = "0.27.0", default-features = false, features = ["alloc", "recovery"], optional = true } +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 } @@ -28,4 +31,3 @@ default = ["secp256k1"] # Only problem that it has, it fails to build for wasm target on windows and mac as it is c lib. # If you dont require wasm on win/mac, i would recommend its usage. secp256k1 = ["dep:secp256k1"] - diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 888335ef13..cccc2b0958 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -10,7 +10,7 @@ mod identity; mod modexp; mod secp256k1; -use once_cell::sync::OnceCell; +use once_cell::race::OnceBox; pub use primitives::{ precompile::{PrecompileError as Error, *}, Bytes, HashMap, @@ -21,7 +21,7 @@ pub use revm_primitives as primitives; pub type B160 = [u8; 20]; pub type B256 = [u8; 32]; -use alloc::vec::Vec; +use alloc::{boxed::Box, vec::Vec}; use core::fmt; pub fn calc_linear_cost_u32(len: usize, base: u64, word: u64) -> u64 { @@ -119,7 +119,7 @@ impl SpecId { impl Precompiles { pub fn homestead() -> &'static Self { - static INSTANCE: OnceCell = OnceCell::new(); + static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { let fun = [ secp256k1::ECRECOVER, @@ -130,14 +130,14 @@ impl Precompiles { .into_iter() .map(From::from) .collect(); - Self { fun } + Box::new(Self { fun }) }) } pub fn byzantium() -> &'static Self { - static INSTANCE: OnceCell = OnceCell::new(); + static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { - let mut precompiles = Self::homestead().clone(); + let mut precompiles = Box::new(Self::homestead().clone()); precompiles.fun.extend( [ // EIP-196: Precompiled contracts for addition and scalar multiplication on the elliptic curve alt_bn128. @@ -156,9 +156,9 @@ impl Precompiles { } pub fn istanbul() -> &'static Self { - static INSTANCE: OnceCell = OnceCell::new(); + static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { - let mut precompiles = Self::byzantium().clone(); + let mut precompiles = Box::new(Self::byzantium().clone()); precompiles.fun.extend( [ // EIP-152: Add BLAKE2 compression function `F` precompile. @@ -176,9 +176,9 @@ impl Precompiles { } pub fn berlin() -> &'static Self { - static INSTANCE: OnceCell = OnceCell::new(); + static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { - let mut precompiles = Self::istanbul().clone(); + let mut precompiles = Box::new(Self::istanbul().clone()); precompiles.fun.extend( [ // EIP-2565: ModExp Gas Cost. diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 3c61a9caa2..a1fd2be8a7 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -14,18 +14,22 @@ bytes = { version = "1.4", default-features = false } hashbrown = "0.14" primitive-types = { version = "0.12", default-features = false } rlp = { version = "0.5", default-features = false } # used for create2 address calculation -ruint = { version = "1.8.0", features = ["primitive-types", "rlp"] } +ruint = { version = "1.8.0", default-features = false, features = [ + "primitive-types", + "rlp", +] } auto_impl = "1.1" bitvec = { version = "1", default-features = false, features = ["alloc"] } bitflags = { version = "2.4.0", default-features = false } # bits B256 B160 crate -fixed-hash = { version = "0.8", default-features = false, features = ["rustc-hex"] } +fixed-hash = { version = "0.8", default-features = false, features = [ + "rustc-hex", +] } #utility hex-literal = "0.4" hex = { version = "0.4", default-features = false, features = ["alloc"] } -to-binary = "0.4" derive_more = "0.99" enumn = "0.1" @@ -42,7 +46,12 @@ proptest-derive = { version = "0.4", optional = true } arbitrary = { version = "1.3", features = ["derive"] } proptest = "1.1" proptest-derive = "0.4" -ruint = { version = "1.10.1", features = ["primitive-types", "rlp", "proptest", "arbitrary"] } +ruint = { version = "1.10.1", features = [ + "primitive-types", + "rlp", + "proptest", + "arbitrary", +] } [features] default = ["std"] diff --git a/crates/primitives/src/bytecode.rs b/crates/primitives/src/bytecode.rs index 395c97cb8a..ea28c9137c 100644 --- a/crates/primitives/src/bytecode.rs +++ b/crates/primitives/src/bytecode.rs @@ -4,7 +4,6 @@ use bitvec::prelude::{bitvec, Lsb0}; use bitvec::vec::BitVec; use bytes::Bytes; use core::fmt::Debug; -use to_binary::BinaryString; /// A map of valid `jump` destinations. #[derive(Clone, Eq, PartialEq, Default)] @@ -14,7 +13,7 @@ pub struct JumpMap(pub Arc>); impl Debug for JumpMap { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("JumpMap") - .field("map", &BinaryString::from(self.0.as_raw_slice())) + .field("map", &hex::encode(self.0.as_raw_slice())) .finish() } } diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 6fe75693ef..9f9e85b63b 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -20,7 +20,6 @@ pub use bytes; pub use bytes::Bytes; pub use hex; pub use hex_literal; -pub use to_binary; /// Address type is last 20 bytes of hash of ethereum account pub type Address = B160; /// Hash, in Ethereum usually keccak256. diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index fd57e970e6..41ff5cb49d 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -15,14 +15,16 @@ revm-interpreter = { path = "../interpreter", version = "1.1.2", default-feature #misc auto_impl = { version = "1.1", default-features = false } -once_cell = { version = "1.17", default-features = false } # Optional serde = { version = "1.0", features = ["derive", "rc"], optional = true } serde_json = { version = "1.0", features = ["preserve_order"], optional = true } # ethersdb -tokio = { version = "1.32", features = ["rt-multi-thread", "macros"], optional = true } +tokio = { version = "1.32", features = [ + "rt-multi-thread", + "macros", +], optional = true } ethers-providers = { version = "2.0", optional = true } ethers-core = { version = "2.0", optional = true } futures = { version = "0.3.27", optional = true } @@ -56,7 +58,7 @@ optional_block_gas_limit = ["revm-interpreter/optional_block_gas_limit"] optional_eip3607 = ["revm-interpreter/optional_eip3607"] optional_gas_refund = ["revm-interpreter/optional_gas_refund"] optional_no_base_fee = ["revm-interpreter/optional_no_base_fee"] -std = ["revm-interpreter/std", "once_cell/std", "rayon"] +std = ["revm-interpreter/std", "rayon"] ethersdb = ["std", "tokio", "futures", "ethers-providers", "ethers-core"] serde = ["dep:serde", "dep:serde_json", "revm-interpreter/serde"] arbitrary = ["revm-interpreter/arbitrary"]