Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix: configure rustls & openssl via feature flag (#703)
Browse files Browse the repository at this point in the history
* chore(etherscan): allow specifying openssl or rustls

* chore(contract): allow specifying openssl or rustls

* chore(solc): allow specifying openssl or rustls

* chore: expose new rustls/openssl features at top level crate

* chore: bump tokio-tungstenite / remove dup rustls version

* chore: bump svm-rs

* fix: feature gate sha2-asm

* ci: remove --all-features from windows tests

* chore: do not enable sha2-asm by default

* fix: do not pull in svm-rs in wasm builds

* chore: use upstream svm again
  • Loading branch information
gakonst authored Dec 19, 2021
1 parent 3c164bc commit d7c29cc
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 89 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,6 @@ jobs:
run: |
rustc -Vv
cargo -V
cargo check --all-features
shell: cmd
# we test without --all-features on Windows so that sha2-asm is not activated.
cargo check
shell: cmd
94 changes: 27 additions & 67 deletions Cargo.lock

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

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ eip712 = ["ethers-contract/eip712", "ethers-core/eip712"]
## providers
ws = ["ethers-providers/ws"]
ipc = ["ethers-providers/ipc"]
rustls = ["ethers-providers/rustls"]
openssl = ["ethers-providers/openssl"]
rustls = ["ethers-providers/rustls", "ethers-etherscan/rustls", "ethers-contract/rustls", "ethers-solc/rustls"]
openssl = ["ethers-providers/openssl", "ethers-etherscan/openssl", "ethers-contract/openssl", "ethers-solc/openssl"]
dev-rpc = ["ethers-providers/dev-rpc"]
## signers
ledger = ["ethers-signers/ledger"]
Expand All @@ -77,8 +77,7 @@ abigen-offline = ["ethers-contract/abigen-offline"]
solc-async = ["ethers-solc/async"]
solc-full = ["ethers-solc/full"]
solc-tests = ["ethers-solc/tests"]


solc-sha2-asm = ["ethers-solc/asm"]

[dependencies]
ethers-contract = { version = "^0.6.0", default-features = false, path = "./ethers-contract" }
Expand All @@ -95,8 +94,6 @@ ethers-providers = { version = "^0.6.0", default-features = false, path = "./eth

[target.'cfg(target_family = "unix")'.dev-dependencies]
ethers-providers = { version = "^0.6.0", default-features = false, path = "./ethers-providers", features = ["ws", "ipc"] }


anyhow = "1.0.39"
rand = "0.8.4"
serde = { version = "1.0.124", features = ["derive"] }
Expand All @@ -109,4 +106,4 @@ bytes = "1.1.0"
# profile for the wasm example
[profile.release.package.ethers-wasm]
# Tell `rustc` to optimize for small code size.
opt-level = "s"
opt-level = "s"
4 changes: 4 additions & 0 deletions ethers-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ ethers-solc = { version = "^0.1.0", path = "../ethers-solc", default-features =
tokio = { version = "1.5", default-features = false, features = ["macros"] }

[features]
default = ["rustls"]
eip712 = ["ethers-derive-eip712", "ethers-core/eip712"]
abigen = ["ethers-contract-abigen/reqwest", "ethers-contract-derive"]
abigen-offline = ["ethers-contract-abigen", "ethers-contract-derive"]
celo = ["legacy", "ethers-core/celo", "ethers-core/celo", "ethers-providers/celo"]
legacy = []

rustls = ["ethers-contract-abigen/rustls"]
openssl = ["ethers-contract-abigen/openssl"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
10 changes: 6 additions & 4 deletions ethers-contract/ethers-contract-abigen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ url = "2.1"
serde_json = "1.0.61"
serde = { version = "1.0.124", features = ["derive"] }
hex = { version = "0.4.2", default-features = false, features = ["std"] }
reqwest = { version = "0.11.3", features = ["blocking"] , optional = true }
reqwest = { version = "0.11.3", default-features = false, features = ["blocking"] , optional = true }
once_cell = "1.8.0"
cfg-if = "1.0.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
# NOTE: this enables wasm compatibility for getrandom indirectly
getrandom = { version = "0.2", features = ["js"] }

[features]
default = ["reqwest"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["reqwest", "rustls"]
openssl = ["reqwest/native-tls"]
rustls = ["reqwest/rustls-tls"]
7 changes: 6 additions & 1 deletion ethers-etherscan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["ethereum", "web3", "etherscan", "ethers"]

[dependencies]
ethers-core = { version = "^0.6.0", path = "../ethers-core", default-features = false }
reqwest = { version = "0.11.7", features = ["json"] }
reqwest = { version = "0.11.7", default-features = false, features = ["json"] }
serde = { version = "1.0.124", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.64", default-features = false }
serde-aux = { version = "3.0.1", default-features = false }
Expand All @@ -28,3 +28,8 @@ serial_test = "0.5.1"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["rustls"]
openssl = ["reqwest/native-tls"]
rustls = ["reqwest/rustls-tls"]
6 changes: 4 additions & 2 deletions ethers-providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bytes = { version = "1.1.0", default-features = false, optional = true }
# tokio
tokio-util = { version = "0.6.9", default-features = false, features = ["io"], optional = true }
tokio = { version = "1.5", default-features = false, optional = true }
tokio-tungstenite = { version = "0.15.0", default-features = false, features = ["connect"], optional = true }
tokio-tungstenite = { version = "0.16.1", default-features = false, features = ["connect"], optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
ws_stream_wasm = "0.7"
Expand All @@ -64,5 +64,7 @@ ws = ["tokio", "tokio-tungstenite"]
ipc = ["tokio", "tokio/io-util", "tokio-util", "bytes"]

openssl = ["tokio-tungstenite/native-tls", "reqwest/native-tls"]
rustls = ["tokio-tungstenite/rustls-tls", "reqwest/rustls-tls"]
# we use the webpki roots so we can build static binaries w/o any root cert dependencies
# on the host
rustls = ["tokio-tungstenite/rustls-tls-webpki-roots", "reqwest/rustls-tls"]
dev-rpc = []
13 changes: 7 additions & 6 deletions ethers-solc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ md-5 = "0.10.0"
thiserror = "1.0.30"
hex = "0.4.3"
colored = "2.0.0"
svm = { package = "svm-rs", version = "0.2.1", optional = true }
glob = "0.3.0"
tracing = "0.1.29"
num_cpus = "1.13.0"
tiny-keccak = { version = "2.0.2", default-features = false }
tempdir = { version = "0.3.7", optional = true }
fs_extra = { version = "1.2.0", optional = true }

[target.'cfg(any(not(any(target_arch = "x86", target_arch = "x86_64")), target_env = "msvc"))'.dependencies]
sha2 = { version = "0.9.8", default-features = false }

[target.'cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(target_env = "msvc")))'.dependencies]
sha2 = { version = "0.9.8", default-features = false, features = ["asm"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
home = "0.5.3"
# SVM is not WASM compatible yet.
# svm = { package = "svm-rs", default-features = false, version = "0.2.1", optional = true }
svm = { package = "svm-rs", git = "https://github.com/roynalnaruto/svm-rs", default-features = false, optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# NOTE: this enables wasm compatibility for getrandom indirectly
Expand All @@ -63,8 +60,12 @@ path = "tests/project.rs"
required-features = ["project-util"]

[features]
default = ["rustls"]
async = ["tokio", "futures-util"]
full = ["async", "svm"]
# Utilities for creating and testing project workspaces
project-util = ["tempdir", "fs_extra"]
tests = []
openssl = ["svm/openssl"]
rustls = ["svm/rustls"]
asm = ["sha2/asm"]

0 comments on commit d7c29cc

Please sign in to comment.