Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: feature flag compiler errors #256

Merged
merged 5 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 5 additions & 6 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ dev = [
"optional_eip3607",
"optional_gas_refund",
]
ethersdb = ["tokio", "futures", "ethers-providers", "ethers-core"]
# deprecated feature
web3db = []
secp256k1 = ["revm_precompiles/secp256k1"]
memory_limit = []
no_gas_measuring = []
optional_balance_check = []
optional_block_gas_limit = []
optional_eip3607 = []
optional_gas_refund = []
std = ["bytes/std", "num_enum/std", "rlp/std", "hex/std"]
secp256k1 = ["revm_precompiles/secp256k1"]
k256 = ["revm_precompiles/k256_ecrecover"]
ethersdb = ["tokio", "futures", "ethers-providers", "ethers-core"]
std = ["bytes/std", "num_enum/std", "rlp/std"]
with-serde = ["serde", "hex/serde", "hashbrown/serde", "ruint/serde"]
# deprecated feature
web3db = []
Copy link
Contributor Author

@Wodann Wodann Dec 16, 2022

Choose a reason for hiding this comment

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

Removed deprecated feature flag web3db, as it will cause cargo t --all-features to fail

7 changes: 5 additions & 2 deletions crates/revm_precompiles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "1.1.2"
bn = { package = "substrate-bn", version = "0.6", default-features = false }
bytes = { version = "1.1", default-features = false }
hashbrown = { version = "0.13" }
k256 = { version = "0.11", default-features = false, features = ["ecdsa", "keccak256"], optional = true }
k256 = { version = "0.11", default-features = false, features = ["ecdsa", "keccak256"] }
num = { version = "0.4.0", default-features = false, features = ["alloc"] }
once_cell = "1.14"
ripemd = { version = "0.1", default-features = false }
Expand All @@ -26,5 +26,8 @@ hex = "0.4"

[features]
default = ["secp256k1"]
k256_ecrecover = ["k256"]
# 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.
secp256k1 = ["dep:secp256k1"]

13 changes: 7 additions & 6 deletions crates/revm_precompiles/src/secp256k1.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use crate::{Error, Precompile, PrecompileAddress, PrecompileResult, StandardPrecompileFn};
use alloc::vec::Vec;
use core::cmp::min;

const ECRECOVER_BASE: u64 = 3_000;

pub const ECRECOVER: PrecompileAddress = PrecompileAddress(
crate::u64_to_b160(1),
Precompile::Standard(ec_recover_run as StandardPrecompileFn),
);

#[cfg(feature = "k256_ecrecover")]
#[cfg(feature = "secp256k1")]
#[allow(clippy::module_inception)]
mod secp256k1 {
use core::convert::TryFrom;
Expand All @@ -35,7 +31,7 @@ mod secp256k1 {
}
}

#[cfg(all(not(feature = "k256_ecrecover"), feature = "secp256k1"))]
#[cfg(not(feature = "secp256k1"))]
#[allow(clippy::module_inception)]
mod secp256k1 {
use crate::B256;
Expand All @@ -60,6 +56,11 @@ mod secp256k1 {
}

fn ec_recover_run(i: &[u8], target_gas: u64) -> PrecompileResult {
use alloc::vec::Vec;
Wodann marked this conversation as resolved.
Show resolved Hide resolved
use core::cmp::min;

const ECRECOVER_BASE: u64 = 3_000;

if ECRECOVER_BASE > target_gas {
return Err(Error::OutOfGas);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revmjs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bytes = "1.2"
getrandom = { version = "0.2", features = ["js"] }
hex = "0.4"
js-sys = "0.3"
revm = { path = "../revm", version = "2.0", default-features = false, features = ["k256"] }
revm = { path = "../revm", version = "2.0", default-features = false }
ruint = { version = "1.7.0", features = ["bn-rs"] }
wasm-bindgen = "0.2"
primitive-types = "0.12"