Skip to content

Commit

Permalink
Correct std feature-flagging
Browse files Browse the repository at this point in the history
If a crate has std set, it should enable std for all dependencies in order to
let them properly select which algorithms to use. Some crates fallback to
slower/worse algorithms on no-std.

Also more aggressively sets default-features = false leading to a *10%*
reduction in the amount of crates coordinator builds.
  • Loading branch information
kayabaNerve committed Oct 31, 2023
1 parent 34bcb9e commit 05dc474
Show file tree
Hide file tree
Showing 19 changed files with 185 additions and 135 deletions.
13 changes: 10 additions & 3 deletions Cargo.lock

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

26 changes: 13 additions & 13 deletions coins/bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2021"
[dependencies]
std-shims = { version = "0.1.1", path = "../../common/std-shims", default-features = false }

thiserror = { version = "1", optional = true }
thiserror = { version = "1", default-features = false, optional = true }

zeroize = { version = "^1.5", default-features = false }
rand_core = { version = "0.6", default-features = false }
Expand All @@ -22,18 +22,18 @@ bitcoin = { version = "0.31", default-features = false, features = ["no-std"] }

k256 = { version = "^0.13.1", default-features = false, features = ["arithmetic", "bits"] }

transcript = { package = "flexible-transcript", path = "../../crypto/transcript", version = "0.3", features = ["recommended"], optional = true }
frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.8", features = ["secp256k1"], optional = true }
transcript = { package = "flexible-transcript", path = "../../crypto/transcript", version = "0.3", default-features = false, features = ["recommended"], optional = true }
frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.8", default-features = false, features = ["secp256k1"], optional = true }

hex = { version = "0.4", optional = true }
serde = { version = "1", features = ["derive"], optional = true }
serde_json = { version = "1", optional = true }
reqwest = { version = "0.11", features = ["json"], optional = true }
hex = { version = "0.4", default-features = false, optional = true }
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1", default-features = false, optional = true }
reqwest = { version = "0.11", default-features = false, features = ["default-tls", "json"], optional = true }

[dev-dependencies]
frost = { package = "modular-frost", path = "../../crypto/frost", features = ["tests"] }

tokio = { version = "1", features = ["full"] }
tokio = { version = "1", features = ["macros"] }

[features]
std = [
Expand All @@ -52,13 +52,13 @@ std = [

"k256/std",

"transcript",
"transcript/std",
"frost",

"hex",
"serde",
"serde_json",
"reqwest"
"hex/std",
"serde/std",
"serde_json/std",
"reqwest",
]
hazmat = []
default = ["std"]
16 changes: 10 additions & 6 deletions coins/monero/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rustdoc-args = ["--cfg", "docsrs"]
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false }

async-trait = { version = "0.1", default-features = false }
thiserror = { version = "1", optional = true }
thiserror = { version = "1", default-features = false, optional = true }

zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] }
subtle = { version = "^2.4", default-features = false }
Expand All @@ -40,8 +40,8 @@ multiexp = { path = "../../crypto/multiexp", version = "0.4", default-features =

# Needed for multisig
transcript = { package = "flexible-transcript", path = "../../crypto/transcript", version = "0.3", default-features = false, features = ["recommended"], optional = true }
dleq = { path = "../../crypto/dleq", version = "0.4", features = ["serialize"], optional = true }
frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.8", features = ["ed25519"], optional = true }
dleq = { path = "../../crypto/dleq", version = "0.4", default-features = false, features = ["serialize"], optional = true }
frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.8", default-features = false, features = ["ed25519"], optional = true }

monero-generators = { path = "generators", version = "0.4", default-features = false }

Expand All @@ -55,7 +55,7 @@ serde_json = { version = "1", default-features = false, features = ["alloc"] }
base58-monero = { version = "2", default-features = false, features = ["check"] }

# Used for the provided HTTP RPC
digest_auth = { version = "0.3", optional = true }
digest_auth = { version = "0.3", default-features = false, optional = true }
hyper = { version = "0.14", default-features = false, features = ["http1", "tcp", "client", "backports", "deprecated"], optional = true }
hyper-rustls = { version = "0.24", default-features = false, features = ["http1", "native-tokio"], optional = true }
tokio = { version = "1", default-features = false, optional = true }
Expand All @@ -65,7 +65,7 @@ dalek-ff-group = { path = "../../crypto/dalek-ff-group", version = "0.4", defaul
monero-generators = { path = "generators", version = "0.4", default-features = false }

[dev-dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "sync", "macros"] }
tokio = { version = "1", features = ["sync", "macros"] }

frost = { package = "modular-frost", path = "../../crypto/frost", features = ["tests"] }

Expand All @@ -79,14 +79,18 @@ std = [
"subtle/std",

"rand_core/std",
"rand_chacha/std",
"rand/std",
"rand_chacha/std",
"rand_distr/std",

"sha3/std",
"pbkdf2/std",

"multiexp/std",

"transcript/std",
"dleq/std",

"monero-generators/std",

"futures/std",
Expand Down
4 changes: 2 additions & 2 deletions common/std-shims/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
spin = { version = "0.9", features = ["mutex", "once"] }
hashbrown = "0.14"
spin = { version = "0.9", default-features = false, features = ["use_ticket_mutex", "once"] }
hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] }

[features]
std = []
Expand Down
2 changes: 2 additions & 0 deletions common/zalloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"]
zeroize = { version = "^1.5", default-features = false }

[features]
std = ["zeroize/std"]
default = ["std"]
# Commented for now as it requires nightly and we don't use nightly
# allocator = []
43 changes: 21 additions & 22 deletions coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,21 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
async-trait = "0.1"
async-trait = { version = "0.1", default-features = false }

zeroize = "^1.5"
rand_core = "0.6"
rand_chacha = "0.3"
zeroize = { version = "^1.5", default-features = false, features = ["std"] }
rand_core = { version = "0.6", default-features = false, features = ["std"] }
rand_chacha = { version = "0.3", default-features = false, features = ["std"] }

blake2 = "0.10"
blake2 = { version = "0.10", default-features = false, features = ["std"] }

transcript = { package = "flexible-transcript", path = "../crypto/transcript", features = ["recommended"] }
ciphersuite = { path = "../crypto/ciphersuite" }
schnorr = { package = "schnorr-signatures", path = "../crypto/schnorr" }
transcript = { package = "flexible-transcript", path = "../crypto/transcript", default-features = false, features = ["std", "recommended"] }
ciphersuite = { path = "../crypto/ciphersuite", default-features = false, features = ["std"] }
schnorr = { package = "schnorr-signatures", path = "../crypto/schnorr", default-features = false, features = ["std"] }
frost = { package = "modular-frost", path = "../crypto/frost" }
frost-schnorrkel = { path = "../crypto/schnorrkel" }

scale = { package = "parity-scale-codec", version = "3", features = ["derive"] }

sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }

serai-db = { path = "../common/db", features = ["rocksdb"] }
serai-env = { path = "../common/env" }
Expand All @@ -39,20 +37,21 @@ processor-messages = { package = "serai-processor-messages", path = "../processo
message-queue = { package = "serai-message-queue", path = "../message-queue" }
tributary = { package = "tributary-chain", path = "./tributary" }

serai-client = { path = "../substrate/client", features = ["serai"] }
serai-client = { path = "../substrate/client", default-features = false, features = ["serai"] }

hex = "0.4"
bincode = "1"
serde_json = { version = "1", default-features = false }
hex = { version = "0.4", default-features = false, features = ["std"] }
bincode = { version = "1", default-features = false }
serde_json = { version = "1", default-features = false, features = ["std"] }

log = "0.4"
env_logger = "0.10"
log = { version = "0.4", default-features = false, features = ["std"] }
env_logger = { version = "0.10", default-features = false, features = ["humantime"] }

futures = "0.3"
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "macros"] }
libp2p = { version = "0.52", features = ["tokio", "tcp", "noise", "yamux", "gossipsub", "mdns", "macros"] }
futures = { version = "0.3", default-features = false, features = ["std"] }
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "sync", "time", "macros"] }
libp2p = { version = "0.52", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "gossipsub", "mdns", "macros"] }

[dev-dependencies]
futures = "0.3"
futures = { version = "0.3", default-features = false, features = ["std"] }
tributary = { package = "tributary-chain", path = "./tributary", features = ["tests"] }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
30 changes: 15 additions & 15 deletions coordinator/tributary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ authors = ["Luke Parker <[email protected]>"]
edition = "2021"

[dependencies]
async-trait = "0.1"
thiserror = "1"
async-trait = { version = "0.1", default-features = false }
thiserror = { version = "1", default-features = false }

subtle = "^2"
zeroize = "^1.5"
subtle = { version = "^2", default-features = false, features = ["std"] }
zeroize = { version = "^1.5", default-features = false, features = ["std"] }

rand = "0.8"
rand_chacha = "0.3"
rand = { version = "0.8", default-features = false, features = ["std"] }
rand_chacha = { version = "0.3", default-features = false, features = ["std"] }

blake2 = "0.10"
transcript = { package = "flexible-transcript", path = "../../crypto/transcript", features = ["recommended"] }
blake2 = { version = "0.10", default-features = false, features = ["std"] }
transcript = { package = "flexible-transcript", path = "../../crypto/transcript", default-features = false, features = ["std", "recommended"] }

ciphersuite = { package = "ciphersuite", path = "../../crypto/ciphersuite", features = ["ristretto"] }
schnorr = { package = "schnorr-signatures", path = "../../crypto/schnorr" }
ciphersuite = { package = "ciphersuite", path = "../../crypto/ciphersuite", default-features = false, features = ["std", "ristretto"] }
schnorr = { package = "schnorr-signatures", path = "../../crypto/schnorr", default-features = false, features = ["std"] }

hex = "0.4"
log = "0.4"
hex = { version = "0.4", default-features = false, features = ["std"] }
log = { version = "0.4", default-features = false, features = ["std"] }

serai-db = { path = "../../common/db" }

scale = { package = "parity-scale-codec", version = "3", features = ["derive"] }
futures = "0.3"
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }
futures = { version = "0.3", default-features = false, features = ["std"] }
tendermint = { package = "tendermint-machine", path = "./tendermint" }

tokio = { version = "1", features = ["sync", "time", "rt"] }
tokio = { version = "1", default-features = false, features = ["sync", "time", "rt"] }

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }
Expand Down
14 changes: 7 additions & 7 deletions coordinator/tributary/tendermint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ authors = ["Luke Parker <[email protected]>"]
edition = "2021"

[dependencies]
async-trait = "0.1"
thiserror = "1"
async-trait = { version = "0.1", default-features = false }
thiserror = { version = "1", default-features = false }

hex = "0.4"
log = "0.4"
hex = { version = "0.4", default-features = false, features = ["std"] }
log = { version = "0.4", default-features = false, features = ["std"] }

parity-scale-codec = { version = "3", features = ["derive"] }
parity-scale-codec = { version = "3", default-features = false, features = ["std", "derive"] }

futures = "0.3"
tokio = { version = "1", features = ["sync", "time"] }
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
tokio = { version = "1", default-features = false, features = ["sync", "time"] }

[dev-dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
27 changes: 24 additions & 3 deletions crypto/ciphersuite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,36 @@ k256 = { version = "^0.13.1", default-features = false, features = ["arithmetic"
minimal-ed448 = { path = "../ed448", version = "0.4", default-features = false, optional = true }

[dev-dependencies]
hex = "0.4"
hex = { version = "0.4", default-features = false, features = ["std"] }

rand_core = { version = "0.6", features = ["std"] }
rand_core = { version = "0.6", default-features = false, features = ["std"] }

ff-group-tests = { version = "0.13", path = "../ff-group-tests" }

[features]
alloc = ["std-shims"]
std = ["zeroize/std", "std-shims/std"]
std = [
"std-shims/std",

"rand_core/std",

"zeroize/std",
"subtle/std",

"digest/std",
"transcript/std",
"sha2?/std",
"sha3?/std",

"ff/std",

"dalek-ff-group?/std",

"elliptic-curve?/std",
"p256?/std",
"k256?/std",
"minimal-ed448?/std",
]

dalek = ["sha2", "dalek-ff-group"]
ed25519 = ["dalek"]
Expand Down
6 changes: 5 additions & 1 deletion crypto/dalek-ff-group/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ sha2 = { version = "0.10", default-features = false }
curve25519-dalek = { version = ">= 4.0, < 4.2", default-features = false, features = ["alloc", "zeroize", "digest", "group", "precomputed-tables"] }

[dev-dependencies]
rand_core = { version = "0.6", features = ["std"] }
rand_core = { version = "0.6", default-features = false, features = ["std"] }
ff-group-tests = { path = "../ff-group-tests" }

[features]
std = ["zeroize/std", "subtle/std", "rand_core/std", "digest/std", "sha2/std"]
default = ["std"]
10 changes: 8 additions & 2 deletions crypto/dkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,22 @@ ciphersuite = { path = "../ciphersuite", default-features = false, features = ["
[features]
std = [
"thiserror",

"rand_core/std",

"std-shims/std",

"ciphersuite/std",
"serde/std",

"multiexp/batch",
"transcript/std",
"chacha20/std",

"ciphersuite/std",
"multiexp/std",
"multiexp/batch",

"schnorr/std",
"dleq/std",
"dleq/serialize"
]
serde = ["dep:serde"]
Expand Down
Loading

0 comments on commit 05dc474

Please sign in to comment.