Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions crates/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand All @@ -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",
]
25 changes: 18 additions & 7 deletions crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ 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`.
secp256k1 = ["dep:secp256k1"]
6 changes: 3 additions & 3 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -197,7 +197,7 @@ impl Precompiles {
static INSTANCE: OnceBox<Precompiles> = 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(
Expand All @@ -210,7 +210,7 @@ impl Precompiles {
);
precompiles
}
#[cfg(not(feature = "std"))]
#[cfg(not(feature = "c-kzg"))]
{
Box::new(Self::berlin().clone())
}
Expand Down
39 changes: 22 additions & 17 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -86,6 +71,7 @@ serde = [
"bytes/serde",
"bitvec/serde",
"bitflags/serde",
"c-kzg?/serde",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!

]
arbitrary = [
"std",
Expand All @@ -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"]
4 changes: 2 additions & 2 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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::*;
Expand Down
20 changes: 13 additions & 7 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -47,19 +53,19 @@ 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"]
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 = []

Expand Down