[package]
name = "smoldot"
version = "1.1.0"
description = "Primitives to build a client for Substrate-based blockchains"
documentation = "https://docs.rs/smoldot"
keywords = ["blockchain", "peer-to-peer"]
authors.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
include.workspace = true

[features]
default = ["database-sqlite", "std", "wasmtime"]
database-sqlite = [
    "dep:parking_lot",
    "dep:rusqlite",
    "std"   # A database stored on the filesystem can't reasonably work without a filesystem.
]
std = [
    "futures-executor/thread-pool",
    "futures-util",
    "dep:pin-project",
    "schnorrkel/getrandom", # TODO: necessary for signing; clarify in docs and in source code
    "dep:soketto",
]
wasmtime = [
    "dep:wasmtime",
    "std"   # TODO: unfortunately doesn't compile without `std`, but could be fixed
]

[dependencies]
# This section contains only no_std-compatible crates. See below for std-only crates.
#
# Before adding a crate here, please make sure that it is `no_std`-compatible. If a crate should
# theoretically be `no_std`-compatible (i.e. doesn't need the help of the operating system) but is
# not, or if things are sketchy, please leave a comment next to it.
arrayvec = { version = "0.7.6", default-features = false }
async-lock = { version = "3.0.0", default-features = false }
atomic-take = { version = "1.1.0" }
base32 = { version = "0.5.1", default-features = false }
base64 = { version = "0.22.0", default-features = false, features = ["alloc"] }
bip39 = { version = "2.0.0", default-features = false }
blake2-rfc = { version = "0.2.18", default-features = false }
bs58 = { version = "0.5.1", default-features = false, features = ["alloc"] }
chacha20 = { version = "0.9.1", default-features = false }
crossbeam-queue = { version = "0.3.11", default-features = false, features = ["alloc"] }
derive_more = { version = "2.0", default-features = false, features = ["full"] }
ed25519-zebra = { version = "4.1.0", default-features = false, features = ["alloc"] }
either = { version = "1.9.0", default-features = false }
event-listener = { version = "5.3.0", default-features = false }
fastbloom = { version = "0.17", default-features = false }
fnv = { version = "1.0.7", default-features = false }
futures-lite = { version = "2.3.0", default-features = false, features = ["alloc"] }
hashbrown = { version = "0.16.0", default-features = false, features = ["raw-entry", "serde"] }   # TODO: remove serde feature
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
hmac = { version = "0.12.1", default-features = false }
itertools = { version = "0.14.0", default-features = false }
libm = { version = "0.2.8", default-features = false }
libsecp256k1 = { version = "0.7.1", default-features = false, features = ["static-context", "hmac"] }
# The log` crate is forbidden, as it is very impolite to emit logs from a library.
merlin = { version = "3.0", default-features = false }
nom = { version = "8.0.0", default-features = false, features = ["alloc"] }
num-bigint = { version = "0.4.3", default-features = false }
num-rational = { version = "0.4.1", default-features = false, features = ["num-bigint"] }
num-traits = { version = "0.2.19", default-features = false }
pbkdf2 = { version = "0.12.1", default-features = false }
poly1305 = { version = "0.8.0", default-features = false }
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
rand_chacha = { version = "0.3.1", default-features = false }
ruzstd = { version = "0.8.0", default-features = false }
schnorrkel = { version = "0.11.2", default-features = false, features = ["preaudit_deprecated", "alloc"] }
serde = { version = "1.0.183", default-features = false, features = ["alloc", "derive"] }
serde_json = { version = "1.0.104", default-features = false, features = ["alloc", "raw_value"] }
sha2 = { version = "0.10.7", default-features = false }
sha3 = { version = "0.10.8", default-features = false }
siphasher = { version = "1.0.1", default-features = false }
slab = { version = "0.4.8", default-features = false }
smallvec = { version = "1.13.2", default-features = false }
twox-hash = { version = "2.0.0", default-features = false, features = ["xxhash64"] }
wasmi = { version = "0.40.0", default-features = false }
x25519-dalek = { version = "2.0.0-rc.3", default-features = false, features = ["alloc", "precomputed-tables", "static_secrets", "zeroize"] }
zeroize = { version = "1.7.0", default-features = false, features = ["alloc"] }

# `database-sqlite` feature
rusqlite = { version = "0.32.1", optional = true, default-features = false, features = ["bundled"] }

# `std` feature
# Add here the crates that cannot function without the help of the operating system or environment.
futures-util = { version = "0.3.27", optional = true, default-features = false, features = ["std",  "io", "async-await-macro", "sink"] }  # TODO: slim down these features
parking_lot = { version = "0.12.1", optional = true }
pin-project = { version = "1.1.5", optional = true }
soketto = { version = "0.8.0", optional = true }

# This list of targets matches the tier 1 and tier 2 of platforms supported by wasmtime: <https://docs.wasmtime.dev/stability-tiers.html>
# The arch and OS of a specific target can be found with the command `rustc +nightly -Z unstable-options --print target-spec-json --target ...`
[target.'cfg(any(all(target_arch = "x86_64", any(target_os = "windows", all(target_os = "linux", target_env = "gnu"), target_os = "macos")), all(target_arch = "aarch64", target_os = "linux", target_env = "gnu"), all(target_arch = "s390x", target_os = "linux", target_env = "gnu")))'.dependencies]
# `wasmtime` feature
# Note that we have to enable more features than needed just in order to disable them, as wasmtime does trickeries such as <https://github.com/bytecodealliance/wasmtime/blob/9fd00a0aaf157c98a1c588e55c844ea27a81a3cf/crates/wasmtime/src/config.rs#L259-L264>
wasmtime = { version = "36.0.7", default-features = false, features = ["async", "cranelift", "gc", "gc-null", "component-model", "threads"], optional = true }

[dev-dependencies]
criterion = "0.5.1"
futures-executor = { version = "0.3.28", default-features = false }
rand = { version = "0.8.5", default-features = false, features = ["std", "std_rng"] }
tempfile = "3.10.0"
wat = "1.216.0"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[[bench]]
name = "header"
harness = false
[[bench]]
name = "proof-decode"
harness = false
