Skip to content

Conversation

@cryptagupta
Copy link

What

Fixes #542

Make the arti (embedded Tor) dependency tree optional behind an arti Cargo feature flag in cuprate-p2p-transport and cuprated. The feature is enabled by default, so existing behavior is unchanged.

Why

The arti dependency tree is substantial (dozens of crates including OpenSSL, SQLite, cryptographic libraries). Making it optional allows faster builds and smaller binaries when embedded Tor support is not needed.

We left the default behaviour to be the current behaviour (i.e. Arti is included).

Type/Build Command/Number of dependencies/Executable size
Without Arti/cargo build --release -p cuprated --no-default-features/432/16M
With Arti/cargo build --release -p cuprated/711/33M

The executable size went from 33M to 16M when Arti was excluded. Arti more than doubles the executable size.

Where

  • p2p/p2p-transport/Cargo.toml — new arti feature, arti/tor-* deps made optional
  • p2p/p2p-transport/src/lib.rsmod arti, mod disabled, and their re-exports gated behind #[cfg(feature = "arti")]
  • binaries/cuprated/Cargo.toml — new arti feature (default-enabled), arti-client/tor-hsservice/tor-persist/tor-rtcompat made optional
  • binaries/cuprated/src/tor.rsTorMode::Arti variant, TorContext arti fields, and arti initialization/transport functions gated
  • binaries/cuprated/src/p2p.rs — arti imports and TorMode::Arti match arms gated
  • binaries/cuprated/src/config.rsTorMode::Arti arms in tor_p2p_config() and dry_run_check() gated
  • binaries/cuprated/src/config/p2p.rs — removed dead arti imports (arti_client::*, tor_rtcompat::*, cuprate_p2p_transport::{Arti, ArtiClientConfig, ArtiServerConfig})

How

All arti/tor-* dependencies are marked optional = true in both Cargo.toml files and grouped under an arti feature. In cuprate-p2p-transport, the existing static feature now depends on arti (static = ["arti", "arti-client/static"]). In cuprated, arti is default-enabled and also activates cuprate-p2p-transport/arti.

All source code that references arti types (TorMode::Arti, TorClient, OnionService, ArtiClientConfig, etc.) is gated with #[cfg(feature = "arti")]. This includes the enum variant itself, struct fields, function definitions, imports, and match arms.

No test modifications were needed. There are no tests in cuprate-p2p-transport, and the cuprated config tests (documented_config, test_read_from_path, test_check_file_permissions) don't reference arti-specific types. The serde round-trip tests work with the feature off because TorMode defaults to Off, so the Arti variant is never serialized or deserialized.

Verified:

  • cargo check -p cuprated --no-default-features builds without arti
  • cargo check -p cuprated builds with arti (default)
  • cargo tree -p cuprated --no-default-features | grep arti returns empty
  • cargo clippy -p cuprate-p2p-transport --all-features -- -D warnings passes
  • cargo clippy -p cuprate-p2p-transport --no-default-features -- -D warnings passes
  • cargo test -p cuprated --no-default-features -- config::test passes
  • cargo test -p cuprated -- config::test passes

All the CI checks were also run. They had a few warnings that were also present when run on the main branch. Some of these warnings (missing imports, type name instead of Self) have also been corrected in this PR.

The arti library pulls in a large dependency tree (dozens of crates,
OpenSSL, SQLite, etc). This makes it optional behind an `arti` feature
flag so builds that don't need embedded Tor support can avoid it.

- Add `arti` feature to `cuprate-p2p-transport` gating all arti/tor-*
  dependencies and the arti module
- Add `arti` feature to `cuprated` (default-enabled) gating arti-client,
  tor-hsservice, tor-persist, and tor-rtcompat
- Gate `TorMode::Arti` variant, `TorContext` arti fields, and all
  arti-specific functions behind `#[cfg(feature = "arti")]`
- Remove unused arti imports from `config/p2p.rs`

Default behavior is unchanged: the `arti` feature is enabled by default
through `default = ["static"]` in p2p-transport and `default = ["arti"]`
in cuprated.
@github-actions github-actions bot added A-p2p Area: Related to P2P. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-net Area: Related to networking. A-binaries Area: Related to binaries. labels Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-binaries Area: Related to binaries. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-net Area: Related to networking. A-p2p Area: Related to P2P.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Arti optional

1 participant