diff --git a/Cargo.lock b/Cargo.lock index 030ac881f0..996fc01c9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -451,6 +451,7 @@ dependencies = [ "glob", "hex", "libc", + "serde", ] [[package]] diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index aa43614127..7140f51b7b 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -10,7 +10,7 @@ version = "1.1.2" readme = "../../README.md" [dependencies] -revm-primitives = { path = "../primitives", version="1.1.2", default-features = false } +revm-primitives = { path = "../primitives", version = "1.1.2", default-features = false } #utility derive_more = "0.99" @@ -32,6 +32,16 @@ proptest-derive = "0.4" [features] default = ["std"] +std = ["revm-primitives/std"] +serde = ["dep:serde", "revm-primitives/serde"] +arbitrary = [ + "std", + "dep:arbitrary", + "dep:proptest", + "dep:proptest-derive", + "revm-primitives/arbitrary", +] + dev = [ "memory_limit", "optional_balance_check", @@ -47,15 +57,3 @@ optional_block_gas_limit = ["revm-primitives/optional_block_gas_limit"] optional_eip3607 = ["revm-primitives/optional_eip3607"] optional_gas_refund = ["revm-primitives/optional_gas_refund"] optional_no_base_fee = ["revm-primitives/optional_no_base_fee"] -std = ["revm-primitives/std"] -serde = [ - "dep:serde", - "revm-primitives/serde", -] -arbitrary = [ - "std", - "dep:arbitrary", - "dep:proptest", - "dep:proptest-derive", - "revm-primitives/arbitrary", -] diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index 576046ed79..9135f13264 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -33,11 +33,24 @@ hex = "0.4" hex = "0.4" [features] -default = ["secp256k1", "std"] -# Used to disable kzg lib as i couldn't make it compile for wasm target -# at least not on mac. -std = ["dep:c-kzg"] -# secp256k1 is used as faster alternative to k256 lib. And in most cases should be default. -# 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. +default = ["std", "c-kzg", "secp256k1"] +std = [ + "revm-primitives/std", + "k256/std", + "num/std", + "once_cell/std", + "ripemd/std", + "sha2/std", + "sha3/std", + "c-kzg?/std", + "secp256k1?/std", +] + +# The following features may not work on all platforms as they depend on C libraries. +# Enables the KZG point evaluation precompile. +c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg"] + +# Use `secp256k1` as a faster alternative to `k256`. +# The problem that `secp256k1` has is it fails to build for `wasm` target on Windows and Mac as it is c lib. +# In Linux it passes. If you don't require to build wasm on win/mac, it is safe to use it and it is enabled by default. secp256k1 = ["dep:secp256k1"] diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 46f4c1bb96..c75f6bcc0a 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -7,7 +7,7 @@ mod blake2; mod bn128; mod hash; mod identity; -#[cfg(feature = "std")] +#[cfg(feature = "c-kzg")] pub mod kzg_point_evaluation; mod modexp; mod secp256k1; @@ -197,7 +197,7 @@ impl Precompiles { static INSTANCE: OnceBox = OnceBox::new(); INSTANCE.get_or_init(|| { // Don't include KZG point evaluation precompile in no_std builds. - #[cfg(feature = "std")] + #[cfg(feature = "c-kzg")] { let mut precompiles = Box::new(Self::berlin().clone()); precompiles.fun.extend( @@ -210,7 +210,7 @@ impl Precompiles { ); precompiles } - #[cfg(not(feature = "std"))] + #[cfg(not(feature = "c-kzg"))] { Box::new(Self::berlin().clone()) } diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 218aeb41e2..5aee6972f9 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -61,23 +61,8 @@ ruint = { version = "1.10.1", features = [ hex = "0.4" [features] -default = ["std"] -dev = [ - "memory_limit", - "optional_balance_check", - "optional_block_gas_limit", - "optional_eip3607", - "optional_gas_refund", - "optional_no_base_fee", -] -memory_limit = [] -no_gas_measuring = [] -optional_balance_check = [] -optional_block_gas_limit = [] -optional_eip3607 = [] -optional_gas_refund = [] -optional_no_base_fee = [] -std = ["bytes/std", "rlp/std", "hex/std", "bitvec/std", "bitflags/std", "dep:c-kzg"] +default = ["std", "c-kzg"] +std = ["bytes/std", "rlp/std", "hex/std", "bitvec/std", "bitflags/std"] serde = [ "dep:serde", "hex/serde", @@ -86,6 +71,7 @@ serde = [ "bytes/serde", "bitvec/serde", "bitflags/serde", + "c-kzg?/serde", ] arbitrary = [ "std", @@ -96,3 +82,22 @@ arbitrary = [ "dep:proptest-derive", "bitflags/arbitrary", ] + +dev = [ + "memory_limit", + "optional_balance_check", + "optional_block_gas_limit", + "optional_eip3607", + "optional_gas_refund", + "optional_no_base_fee", +] +memory_limit = [] +no_gas_measuring = [] +optional_balance_check = [] +optional_block_gas_limit = [] +optional_eip3607 = [] +optional_gas_refund = [] +optional_no_base_fee = [] + +# See comments in `revm-precompile` +c-kzg = ["dep:c-kzg"] diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index 8d4e58a40a..ec33507942 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -237,8 +237,8 @@ pub struct CfgEnv { pub chain_id: u64, pub spec_id: SpecId, /// KZG Settings for point evaluation precompile. By default, this is loaded from the ethereum mainnet trusted setup. + #[cfg(feature = "c-kzg")] #[cfg_attr(feature = "serde", serde(skip))] - #[cfg(feature = "std")] pub kzg_settings: crate::kzg::EnvKzgSettings, /// Bytecode that is created with CREATE/CREATE2 is by default analysed and jumptable is created. /// This is very beneficial for testing and speeds up execution of that bytecode if called multiple times. @@ -355,7 +355,7 @@ impl Default for CfgEnv { perf_analyse_created_bytecodes: AnalysisKind::default(), limit_contract_code_size: None, disable_coinbase_tip: false, - #[cfg(feature = "std")] + #[cfg(feature = "c-kzg")] kzg_settings: crate::kzg::EnvKzgSettings::Default, #[cfg(feature = "memory_limit")] memory_limit: (1 << 32) - 1, diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index e41ef8b2e8..6e1803a770 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -7,7 +7,7 @@ pub mod bytecode; pub mod constants; pub mod db; pub mod env; -#[cfg(feature = "std")] +#[cfg(feature = "c-kzg")] pub mod kzg; pub mod log; pub mod precompile; @@ -27,7 +27,7 @@ pub use env::*; pub use hashbrown::{hash_map, hash_set, HashMap, HashSet}; pub use hex; pub use hex_literal; -#[cfg(feature = "std")] +#[cfg(feature = "c-kzg")] pub use kzg::{EnvKzgSettings, KzgSettings}; pub use log::Log; pub use precompile::*; diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index dd5fd8d3cf..96fbb56aee 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -38,7 +38,13 @@ bytes = "1.5.0" criterion = "0.5" [features] -default = ["std", "secp256k1"] +default = ["std", "c-kzg", "secp256k1"] +std = ["revm-interpreter/std", "revm-precompile/std"] +serde = ["dep:serde", "dep:serde_json", "revm-interpreter/serde"] +arbitrary = ["revm-interpreter/arbitrary"] + +ethersdb = ["std", "tokio", "futures", "ethers-providers", "ethers-core"] + dev = [ "memory_limit", "optional_balance_check", @@ -47,7 +53,6 @@ dev = [ "optional_gas_refund", "optional_no_base_fee", ] -secp256k1 = ["revm-precompile/secp256k1"] memory_limit = ["revm-interpreter/memory_limit"] no_gas_measuring = ["revm-interpreter/no_gas_measuring"] optional_balance_check = ["revm-interpreter/optional_balance_check"] @@ -55,11 +60,12 @@ 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", "revm-precompile/std"] -ethersdb = ["std", "tokio", "futures", "ethers-providers", "ethers-core"] -serde = ["dep:serde", "dep:serde_json", "revm-interpreter/serde"] -arbitrary = ["revm-interpreter/arbitrary"] -# deprecated feature + +# See comments in `revm-precompile` +secp256k1 = ["revm-precompile/secp256k1"] +c-kzg = ["revm-precompile/c-kzg"] + +# deprecated features web3db = [] with-serde = []