onionwire/docs/ARTI_UPGRADE.md
agent 90d982b369
All checks were successful
ci / test (pull_request) Successful in 31m8s
ci / sdk (pull_request) Successful in 1m34s
android-ci / android (pull_request) Successful in 18m10s
deps: bump the Arti set tor-* 0.46 -> 0.49 (Arti 2.9.0)
Arti publishes these in lockstep. Bumped together:
- arti-client 0.46 -> 0.49 (root + crates/onionwire-sdk, both lockfiles)
- tor-cell, tor-hsservice, tor-rtcompat 0.46 -> 0.49
- safelog 0.9 -> 0.10 (same repo; 0.49's HsId implements safelog 0.10's
  DisplayRedacted, so the old direct pin broke display_redacted)

Arti 0.49 (Arti 2.9.0, 2026-12-01) carries a medium-severity security fix
(TROVE-2026-078, custom build flags) and two low-severity fixes.

MSRV unchanged: Arti 0.49 needs rustc 1.92, the repo floor stays 1.98
(cuprate-daemon / tapes). Only docs/comments moved; src/hs.rs workarounds
rechecked against 0.49: tor-hsservice OVERALL_UPLOAD_TIMEOUT is still 5 min
(PUBLISH_WAIT 360s stands) and tor-config's Listen is still IP-only.

Verified: cargo test --locked (173 lib + all integration suites), clippy
--locked --all-targets -D warnings, SDK cargo test/clippy, live ignored
tor_hs + two_node tests, and scripts/build-android-local.sh (APK + AAR).
2026-12-02 02:37:17 -05:00

163 lines
8.3 KiB
Markdown

# Upgrading the Arti / Tor crates
The in-process Tor stack is the largest attack surface in OnionWire. Arti's
onion services are still **experimental** and OnionWire does not fall back to a
C-tor subprocess, so an upstream fix only reaches users when we bump these
crates, rebuild, and cut a release.
## What is pinned
Direct dependencies that come from the Arti repository, exactly as
`Cargo.toml` has them:
| crate | requirement | features in `Cargo.toml` |
|---|---|---|
| `arti-client` | `0.49` | `default-features = false`; `tokio`, `onion-service-client`, `onion-service-service`, `compression` |
| `tor-cell` | `0.49` | — |
| `tor-hsservice` | `0.49` | — |
| `tor-rtcompat` | `0.49` | `tokio` |
| `safelog` | `0.10` | — |
`snow`, `rusqlite`, `ratatui`, and the rest are unrelated to Arti and are not
part of a Tor upgrade. `safelog` lives in the Arti repository and moves in
lockstep with the `tor-*` set: a stale direct `safelog` pin puts two copies in
the graph, and `HsId::display_redacted` then resolves against the wrong trait
(`error[E0599]: no method named display_redacted`). The SDK workspace
(`crates/onionwire-sdk`) has its own `arti-client` pin and lockfile; bump it
too.
Two crate features re-expose Arti's TLS backends, which Arti marks
**non-additive** — exactly one may be selected per build graph:
* `rustls` (**default**) → every build: the Linux TUI, the released binaries and
the Android SDK. No system OpenSSL is needed for TLS; the root `Cargo.toml`
pins rustls's `ring` feature so the crypto provider resolves from crate
features (without it the rustls backend compiles with no provider).
* `native-tls` → opt-in only, via OpenSSL.
Published Arti releases move all of the crates above together in lockstep.
Bump them as **one set**. A mixed set (e.g. `arti-client` 0.47 with
`tor-hsservice` 0.49) is not a configuration anyone tests upstream, and cargo
will usually refuse or silently pick one `tor-*` version and mismatched
`tor-*` internals fail at runtime.
## Toolchain floor
**rustc 1.98+.** `Cargo.toml` sets `edition = "2024"` and `rust-version = "1.98"`.
Arti 0.49 itself requires only 1.92; the higher floor is the default
`cuprate-daemon` feature (`tapes` calls `VecDeque::pop_front_if`, stable since
1.93). CI builds inside `rust:1.98-bookworm`
(`RUST_IMAGE` in `.forgejo/workflows/ci.yml` and `release.yml`).
A bump may raise the floor. Take the actual MSRV from the upstream release
notes / the crate's own `rust-version`, then raise it in the same PR:
* `rust-version` in `Cargo.toml`,
* `RUST_IMAGE` in `.forgejo/workflows/ci.yml` **and** `.forgejo/workflows/release.yml`,
* the "Rust 1.98+" line in `README.md`.
## How this gets noticed
`.forgejo/workflows/arti-watch.yml` runs daily (and on demand) and asks
crates.io for the newest stable version of each crate above. If the
major.minor moved past the pin, it files one Forgejo issue titled
`Arti upstream: <crate> <pin> → <new>`. It is deduped on that title across open
and closed issues, so re-running it never files a second issue and never
comments. It changes nothing: no `Cargo.toml`, no lockfile, no commit.
Test the alert path without waiting for upstream (it compares real crates.io
data against a pretend pin):
```
# Actions → arti-watch → Run workflow, simulate_pin = arti-client=0.45
python3 scripts/arti-watch.py --dry-run --cargo-toml Cargo.toml --simulate-pin arti-client=0.45
```
**What the watcher does not cover.** It does not subscribe to Tor Project
security announcements — a fix that ships without a crates.io version bump is
invisible to it. It will not catch a yanked crate, and it will not catch a
vulnerability in a version that has not changed. Watch
<https://blog.torproject.org/> and <https://forum.torproject.org/> yourself, and
treat a Tor security advisory as an instruction to bump **now**, ahead of any
issue the watcher files.
## Procedure
1. Read the upstream release notes (Arti tags: <https://gitlab.torproject.org/tpo/core/arti/-/releases>)
and the CHANGELOG for breaking API changes. Check the new MSRV.
2. Branch from `main`; bump every Arti-repository pin in `[dependencies]` of
`Cargo.toml` together (`arti-client`, `tor-cell`, `tor-hsservice`,
`tor-rtcompat`, and `safelog`), the matching `arti-client` pin in
`crates/onionwire-sdk/Cargo.toml`, and `rust-version` if the floor moved.
3. Refresh the lockfile (CI builds with `--locked` and `Cargo.lock` is
committed):
```
cargo update -p arti-client -p tor-cell -p tor-hsservice -p tor-rtcompat -p safelog
git diff --stat Cargo.lock
```
Expect the whole `tor-*` family to move in the diff. A single `tor-*` crate
moving alone is a sign the set is not actually lockstep — stop and look.
Then refresh the SDK workspace's separate lockfile:
```
( cd crates/onionwire-sdk && cargo update -p arti-client )
```
4. Build and run the offline suite:
```
cargo test --locked
cargo clippy --locked --all-targets -- -D warnings
```
5. Re-check the workarounds in `src/hs.rs`. They exist because Arti's publish
path is slow and its circuit timeouts misbehave on hidden-service circuits,
and an upstream fix or behaviour change can make any of them wrong:
| constant | why | guard |
|---|---|---|
| `PUBLISH_WAIT` (360s) | a 180s wait cut a working HsDir upload while status was still `Bootstrapping`; Arti's per-HsDir `OVERALL_UPLOAD_TIMEOUT` is 5 min | `tests/hs.rs::publish_wait_covers_hsdir_retries` |
| `CBT_MIN_TIMEOUT_MS` / `CBT_INITIAL_TIMEOUT_MS` (≥ 10s) | learned circuit-build timeouts can drop to ~1s and kill 4-hop vanguard HsDir circuits | `tests/hs.rs::cbt_min_timeout_floor_is_at_least_10s`, `cbt_initial_timeout_matches_the_floor` |
| `PREEMPTIVE_PREDICTED_PORTS` (empty) | Arti's default predicted 80/443 exit circuits starve IPT + HsDir builds; OnionWire never exits | `tests/hs.rs::no_preemptive_exit_ports` |
| `hs_is_ready` probe semantics | combined status stays `Bootstrapping` after descriptors are already fetchable | `tests/hs.rs::bootstrapping_is_not_ready_until_a_probe_connects` |
Do not paper over a slow publish by raising `PUBLISH_WAIT` — first make sure
the rend handler is spawned *before* the probe wait, or the probe cannot
succeed at all.
6. Run the live two-node test on a networked machine. This is the only test that
proves the hidden service actually publishes and that a second node can
reach it:
```
cargo test --locked --test tor_hs -- --ignored --nocapture
```
It needs minutes of real Tor network. `two_node_byte_pipe_restart_and_dormant`
covers: onion publish (first-run `hs status: Bootstrapping` spam is HsDir
descriptor upload, not a hang), probe-connect against a live HS, a byte pipe
in both directions, restart, and the dormant/offline path.
7. Confirm the fail-closed path by hand if the publish wait changed at all:
with the publish wait still 360s, if Arti cannot publish the onion the
process must exit (no C-tor fallback). Chat to a *reachable-HS but down peer*
is queued locally (`src/outbox.rs`) and retried; file transfer and payment
frames still fail immediately. There is no **server-side** outbox.
8. Rebuild the Android target. The root crate defaults to `rustls` now, so this
is less about exercising a non-default feature than about proving the default
still cross-compiles where OpenSSL does not exist:
```
scripts/build-android-local.sh
```
9. Verify the ciphertext claim still holds after the bump: send a message
between the two nodes, then
```
grep -r "<a distinctive message body>" <nodes' Arti state dirs and sqlite files>
```
must find nothing. The bodies live in sqlite as ciphertext, and nothing about
the plaintext should appear in Arti's state directory.
10. Open a PR against `main` describing: crates bumped, MSRV, the live-test
output, and anything upstream changed that touches `src/hs.rs`. Do not push
`main`. Releases are **manual and batched**: dispatch
`.forgejo/workflows/release.yml` (`dry_run=true` first). A merge does not
mint a release. See [RELEASING.md](RELEASING.md).
## Rolling back
Revert the version bump and the lockfile stanza together, re-run step 3's
`cargo update` only if the revert leaves the lockfile inconsistent, and re-run
`cargo test --locked` plus the live two-node test. Never leave `Cargo.toml` and
`Cargo.lock` out of step: CI builds with `--locked` and will fail, which is the
intent.