Dependency Inflation #8
Replies: 3 comments 4 replies
-
I love where your head's at. :^) I agree with the spirit of this. Are there particular dependencies you'd flag as concerning? Happy to discuss specifics. More broadly, here are some ideas: Types of RiskWhen talking about "security", it's helpful to identify the specific attack vectors we want to protect against.
Of course, we're completely dependent on the Rust toolchain itself---rustc, cargo, the standard library, and core crates like libc. This is a massive point of trust for which there's no real competition or alternative. Are there others? TradeoffsEngineering is always about tradeoffs, of course. Fewer dependencies means less supply chain risk but more code to maintain. More dependencies means faster development but larger attack surface. There's no universally correct answer, just context-dependent choices. The right level of dependency aversion probably changes as the project matures. Early on, velocity matters more. Later, when the code is running big money, the calculus shifts toward minimizing risk. Mitigation Strategies
Minimizing DependenciesSome guidelines we can follow:
Argument for Dependencies
That said, I'm not opposed to pulling dependencies out as an ongoing background effort. Replacing a dependency with a better dependency or custom code could be a nice bounded task for new contributors who want to get familiar with the codebase. Next ActionsAnyone want to do a dependency audit? I haven't been too careful thus far. We could go through Cargo.toml and flag anything that feels sketchy or unnecessarily heavy. I'm open to cutting things that don't pull their weight. |
Beta Was this translation helpful? Give feedback.
-
Dependency Audit ResultsRan an audit of the workspace dependencies. Here's what we found. Current state: 40 direct dependencies in Dead Dependencies (zero usage in source)Confirmed by both manual analysis and
Removing these is risk-free — 15 exclusive transitive crates eliminated, zero code changes needed. Note on Straightforward Removals (small code replacements)
11 more transitive crates eliminated, ~50 lines of replacement code. Biggest Single Win:
|
| Crate | Exclusive deps | Notes |
|---|---|---|
utoipa-swagger-ui |
8 | Embeds a full web app. Could serve raw OpenAPI JSON and drop the embedded UI. |
crc_all |
1 | Niche single-maintainer crate. CRC-5 and CRC-16 are ~20 lines each to implement inline. |
nix (production) |
0 | Used for 1 fstat call; replace with direct libc. Keep as dev-dep for PTY tests. |
hex (mujina-miner) |
1 | ~30 call sites (lots in tests). Could migrate to bitcoin::hex utilities. |
Keep (justified)
tokio, axum, bitcoin, serde, tracing, inventory, slotmap, rustix, tokio-serial, parking_lot, time — all serve core purposes with no lighter alternative.
Potential Total Reduction
From ~149 unique crates down to ~80–90, a 40–50% reduction in dependency surface if all tiers are addressed.
Longer-term: CI Enforcement
To prevent dependency creep, a GitHub Actions workflow running cargo-machete (fast, stable Rust, heuristic) and cargo +nightly udeps (compiler-accurate) on every PR would catch unused dependencies before they're merged. The project currently has no CI — adding fmt/clippy/test/unused-deps checks would match what just checks does locally.
Beta Was this translation helpful? Give feedback.
-
|
Nice work. Happy to take PRs related to this. Maybe I'll tag this as a good first issue for would-be contributors. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
For something that might eventually move towards being a backend to a trillion dollar asset, a large number of (transitive) dependencies (especially ones that are predominately maintained by a single person) is a critical security issue for the entire network. It'd be nice to go ahead and reduce (non-dev) dependencies early to avoid overly depending on them and finding them hard to remove later.
Beta Was this translation helpful? Give feedback.
All reactions