diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 526b314..6cb4f58 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -116,8 +116,6 @@ jobs: -w /src \ "$RUST_IMAGE" \ sh -euxc 'mkdir -p /src /target/tmp && tar xzf - -C /src && cd /src \ - && apt-get update \ - && apt-get install -y --no-install-recommends cmake build-essential \ && rustup component add clippy \ && cargo test --locked \ && cargo clippy --locked --all-targets -- -D warnings' @@ -133,11 +131,8 @@ jobs: # `v*.*.*` — while both the root suites and local `cargo test` stay green. # Build it here. # - # The root `test` job installs `cmake` and `build-essential` (g++, make) because - # the default feature set includes `cuprate-daemon`. RandomX's build script - # calls cmake; without it the job dies with "is cmake not installed?" (os error 2). - # It still does not install `pkg-config`/`libssl-dev` — the root crate defaults - # to Arti's rustls backend, so TLS needs no system OpenSSL. + # The root `test` job no longer installs `pkg-config`/`libssl-dev` — the root + # crate defaults to Arti's rustls backend, so TLS needs no system OpenSSL. # The `rusqlite` `bundled-sqlcipher-vendored-openssl` feature that both jobs # use compiles OpenSSL from source, which needs `perl` and `make` (present in # the `rust:*-bookworm` image), not the `-dev` headers. This job keeps the diff --git a/.forgejo/workflows/fuzz.yml b/.forgejo/workflows/fuzz.yml index ec02d91..e714fcc 100644 --- a/.forgejo/workflows/fuzz.yml +++ b/.forgejo/workflows/fuzz.yml @@ -79,7 +79,7 @@ jobs: "$RUST_IMAGE" \ sh -euxc 'mkdir -p /src /target/tmp && tar xzf - -C /src && cd /src \ && apt-get update \ - && apt-get install -y --no-install-recommends pkg-config libssl-dev cmake build-essential \ + && apt-get install -y --no-install-recommends pkg-config libssl-dev \ && rustup toolchain install nightly --profile minimal \ && rustup default nightly \ && cargo install cargo-fuzz --locked \ diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index ae06aff..ac5e6ef 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -218,7 +218,7 @@ jobs: "$RUST_IMAGE" \ sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \ && apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true update \ - && apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev cmake build-essential \ + && apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev \ && cargo build --release --locked \ && strip /target/release/onionwire \ && ls -l /target/release/onionwire' @@ -301,7 +301,7 @@ jobs: "$RUST_IMAGE" \ sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \ && apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true update \ - && apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev cmake build-essential \ + && apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev \ && cargo build --release --locked \ && strip /target/release/onionwire \ && ls -l /target/release/onionwire' diff --git a/Cargo.toml b/Cargo.toml index d9bcf62..4bd00bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,14 +17,13 @@ repository = "https://github.com/sirius0xdev/onionwire" # every build by rusqlite's `bundled-sqlcipher-vendored-openssl`, vendored and # static: that is the SQLCipher layer, not Arti's TLS.) [features] -default = ["rustls", "cuprate-daemon"] +default = ["rustls"] native-tls = ["arti-client/native-tls"] rustls = ["arti-client/rustls"] # In-process Monero chain daemon (Cuprate) as the local chain source, instead of -# spawning `monerod`. ON in the Linux TUI/release binary (this default). A build -# with `--no-default-features` does not include it. `cuprated` is pre-1.0 and is -# not published to crates.io (every Cuprate crate there is a `0.0.0-placeholder` -# name reservation), so this pins a git revision and pulls a large tree (RandomX, +# spawning `monerod`. OFF by default: `cuprated` is pre-1.0 and is not published +# to crates.io (every Cuprate crate there is a `0.0.0-placeholder` name +# reservation), so this pins a git revision and pulls a large tree (RandomX, # fjall, axum/hyper, rayon). See `docs/WALLET.md`, "The in-process chain daemon". # # Cuprate's own `arti` feature stays OFF (and is off in its default feature set, diff --git a/docs/THREAT_MODEL.md b/docs/THREAT_MODEL.md index dadf0cf..8075e96 100644 --- a/docs/THREAT_MODEL.md +++ b/docs/THREAT_MODEL.md @@ -219,9 +219,8 @@ the app does not pick a public remote node for them. Unsynced or not running is an honest “not ready” / unverified state, not a fake success. -2. **An in-process daemon** (Cuprate, behind the `cuprate-daemon` feature, on in - the Linux TUI/release binary; a `--no-default-features` build does not - include it). P2P, consensus and RandomX run in the OnionWire process; nothing is +2. **An in-process daemon** (Cuprate, behind the `cuprate-daemon` feature, off by + default). P2P, consensus and RandomX run in the OnionWire process; nothing is spawned and nothing leaves the device except the chain P2P traffic itself. What that changes: there is **no daemon operator** to trust — your own process is the daemon, so the "operator sees your addresses" question does not exist. diff --git a/docs/WALLET.md b/docs/WALLET.md index 71d4564..fe11888 100644 --- a/docs/WALLET.md +++ b/docs/WALLET.md @@ -158,16 +158,12 @@ Settings live in the sealed `wallet_child` record (`ChildConfig`: `source`, ### The in-process chain daemon (`cuprate-daemon`) ``` -cargo build --release --bin onionwire +cargo build --release --features cuprate-daemon ``` -That is the Linux TUI/release build. It includes the in-process daemon. -`--features cuprate-daemon` still selects it; that flag is no longer required -for the TUI. A build with `--no-default-features` does not include the daemon. - -- **On in the Linux TUI default.** `cuprated` is pre-1.0, not on crates.io - (placeholder crates), git-pinned. Without the feature, a stored in-process - source can still be read back, but start fails with +- **Off by default.** `cuprated` is pre-1.0, not on crates.io (placeholder + crates), git-pinned, behind the feature. Without the feature, a stored + in-process source can still be read back, but start fails with `this build has no in-process chain daemon — rebuild with --features cuprate-daemon`. - **Pre-production.** Cuprate's own user book says do not use `cuprated` for serious purposes. RPC parity is incomplete (`docs/cuprate-launch-spike.md`). diff --git a/src/cuprate.rs b/src/cuprate.rs index a13ea92..5ef6922 100644 --- a/src/cuprate.rs +++ b/src/cuprate.rs @@ -11,8 +11,7 @@ //! Locked facts this module encodes: //! //! * `cuprated` is a **git** dependency pinned to a revision, behind the -//! `cuprate-daemon` feature, which the Linux TUI default includes. A -//! `--no-default-features` build does not. Cuprate is pre-1.0 and is not +//! `cuprate-daemon` feature, off by default. Cuprate is pre-1.0 and is not //! published to crates.io (every Cuprate crate there is a `0.0.0-placeholder` //! name reservation), so a pinned revision is the only honest way to depend on //! it. diff --git a/src/node.rs b/src/node.rs index fd52ab1..ed4d666 100644 --- a/src/node.rs +++ b/src/node.rs @@ -3364,55 +3364,12 @@ pub(crate) mod tests { node.stop_wallet_child().expect("stop"); } - /// Holds [`crate::wallet_child::test_support::unrestricted_port_lock`] on a - /// thread of its own. The guard is not `Send`, and this test awaits, so the - /// async fn must not hold it (`clippy::await_holding_lock`). - #[cfg(feature = "cuprate-daemon")] - struct UnrestrictedPortHold { - tx: Option>, - handle: Option>, - } - - #[cfg(feature = "cuprate-daemon")] - impl UnrestrictedPortHold { - fn new() -> Self { - let (ready_tx, ready_rx) = std::sync::mpsc::channel(); - let (tx, rx) = std::sync::mpsc::channel(); - let handle = std::thread::spawn(move || { - let _guard = crate::wallet_child::test_support::unrestricted_port_lock(); - let _ = ready_tx.send(()); - let _ = rx.recv(); - }); - ready_rx - .recv() - .expect("the port lock thread must answer before the test binds"); - Self { - tx: Some(tx), - handle: Some(handle), - } - } - } - - #[cfg(feature = "cuprate-daemon")] - impl Drop for UnrestrictedPortHold { - fn drop(&mut self) { - drop(self.tx.take()); - if let Some(handle) = self.handle.take() { - let _ = handle.join(); - } - } - } - /// The case the user hit: the wallet RPC is refused (`os error 111`) while /// the chain source is this box's own daemon. The status still shows the /// chain's height and target — asked of the daemon directly — and the state /// stays `connecting`, because the *wallet* is what did not answer. #[tokio::test] async fn a_refused_wallet_rpc_falls_back_to_the_local_daemons_own_height() { - // The in-process launch tests bind this same port. Hold it for the - // whole test so a default build (feature on) does not race them. - #[cfg(feature = "cuprate-daemon")] - let _port = UnrestrictedPortHold::new(); let dir = tempfile::tempdir().unwrap(); let home = dir.path().join("child"); let Some(()) = mock_daemon_on_default_port(1160, 3_090_939).await else { @@ -3501,149 +3458,6 @@ pub(crate) mod tests { assert!(err.contains("no chain source configured"), "{err}"); } - /// The call the TUI makes. A direct `CuprateNode::launch` does not prove - /// `start_wallet_child` pointed the wallet child at that node. - /// - /// Testnet, no peers: RPC answers at genesis. Not a sync. - #[cfg(feature = "cuprate-daemon")] - #[test] - fn start_wallet_child_in_process_cuprate_answers_get_info() { - let _port = crate::wallet_child::test_support::unrestricted_port_lock(); - let rt = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .expect("runtime"); - rt.block_on(start_wallet_child_in_process_cuprate_answers_get_info_inner()); - } - - #[cfg(feature = "cuprate-daemon")] - async fn start_wallet_child_in_process_cuprate_answers_get_info_inner() { - let dir = tempfile::tempdir().unwrap(); - let home = dir.path().join("child"); - let node = offline_node(&home, Arc::new(NoDial)); - let log = dir.path().join("wallet-rpc.argv"); - let bin = fake_child_bin( - &dir.path().join("fake-bins"), - "monero-wallet-rpc", - &log, - "sleep 60", - ); - node.set_in_process_cuprate(ChainNetwork::Testnet, false) - .expect("store an in-process testnet source"); - let mut cfg = node.wallet_child_config(); - let ChainSource::InProcessCuprate { - datadir, - network, - prune, - } = &cfg.source - else { - panic!("stored source is not in-process: {:?}", cfg.source); - }; - assert_eq!(*network, ChainNetwork::Testnet); - assert!(!prune); - assert!( - datadir.starts_with(&home), - "datadir must live under the wallet home: {}", - datadir.display() - ); - let datadir = datadir.clone(); - cfg.wallet_rpc_bin = bin; - node.set_wallet_child_config(&cfg) - .expect("point the child at the fake wallet rpc"); - assert!( - WalletChild::chain_copy(&node.wallet_child_config().source) - .contains(crate::cuprate::TESTNET_ONLY), - "an in-process status line must keep the testnet caveat" - ); - - let _hold = PublishedPortHold::watching(std::slice::from_ref(&log)); - node.start_wallet_child() - .expect("the TUI start path launches the in-process daemon"); - - let addr = format!("127.0.0.1:{DEFAULT_MONEROD_RPC_PORT}"); - let mut argv = String::new(); - for _ in 0..200 { - argv = std::fs::read_to_string(&log).unwrap_or_default(); - if argv.contains("--daemon-address") { - break; - } - tokio::time::sleep(Duration::from_millis(10)).await; - } - let lines: Vec<&str> = argv.lines().collect(); - assert!( - lines - .windows(2) - .any(|w| w == ["--daemon-address", addr.as_str()]), - "the wallet child must be pointed at the in-process RPC, got {argv}" - ); - - let budget = Duration::from_secs(5); - let mut info = None; - for _ in 0..40 { - if let Ok(got) = wallet::daemon_get_info(&addr, budget).await { - info = Some(got); - break; - } - tokio::time::sleep(Duration::from_millis(250)).await; - } - let info = info.expect("the unrestricted RPC the child points at never answered get_info"); - assert!(info.height >= 1, "genesis is height 1: {info:?}"); - assert_eq!( - info.target_height, 0, - "a testnet node with no peers reports no target: {info:?}" - ); - assert!( - datadir.join("testnet").join("fjall").is_dir(), - "the chain store must live under the wallet home: {}", - datadir.display() - ); - - node.stop_wallet_child().expect("stop"); - let mut closed = false; - for _ in 0..40 { - if tokio::net::TcpStream::connect(&addr).await.is_err() { - closed = true; - break; - } - tokio::time::sleep(Duration::from_millis(250)).await; - } - assert!( - closed, - "the unrestricted RPC was still accepting after stop_wallet_child" - ); - } - - /// Same call, feature off: the refusal names the feature and spawns nothing. - #[cfg(not(feature = "cuprate-daemon"))] - #[tokio::test] - async fn start_wallet_child_without_the_feature_returns_no_feature_msg() { - let dir = tempfile::tempdir().unwrap(); - let home = dir.path().join("child"); - let node = offline_node(&home, Arc::new(NoDial)); - let log = dir.path().join("wallet-rpc.argv"); - let bin = fake_child_bin( - &dir.path().join("fake-bins"), - "monero-wallet-rpc", - &log, - "sleep 30", - ); - node.set_in_process_cuprate(ChainNetwork::Testnet, false) - .expect("store an in-process source"); - let mut cfg = node.wallet_child_config(); - cfg.wallet_rpc_bin = bin; - node.set_wallet_child_config(&cfg).expect("set bin"); - - let err = node - .start_wallet_child() - .expect_err("a build without the feature must not start a daemon"); - assert!(err.contains(crate::cuprate::NO_FEATURE_MSG), "{err}"); - assert!( - !log.exists(), - "the wallet RPC must not be spawned against a daemon that never started" - ); - assert!(!node.wallet_child_status().running, "{err}"); - } - /// The start path honours `with_wallet_rpc_bin` — the configured absolute /// path is what gets spawned, not a name off `PATH` — and the status tracks /// the real process. diff --git a/src/wallet_child.rs b/src/wallet_child.rs index d10746d..d61dab8 100644 --- a/src/wallet_child.rs +++ b/src/wallet_child.rs @@ -2150,7 +2150,6 @@ mod tests { #[cfg(feature = "cuprate-daemon")] #[test] fn in_process_source_launches_a_daemon_and_stop_shuts_it_down() { - let _port = super::test_support::unrestricted_port_lock(); let dir = tmp_dir("cuprate-on"); let store = open_store(&dir); let rpc_log = dir.join("wallet-rpc.argv"); @@ -2205,7 +2204,6 @@ mod tests { #[cfg(feature = "cuprate-daemon")] #[test] fn a_start_that_fails_after_the_daemon_came_up_leaves_nothing_running() { - let _port = super::test_support::unrestricted_port_lock(); let dir = tmp_dir("cuprate-late-failure"); let store = open_store(&dir); let rpc_log = dir.join("wallet-rpc.argv"); @@ -2372,18 +2370,6 @@ pub(crate) mod test_support { use std::sync::atomic::{AtomicBool, Ordering}; use std::time::{Duration, SystemTime}; - /// Every in-process launch binds [`DEFAULT_MONEROD_RPC_PORT`]. `cargo test` - /// runs those tests in parallel, so they take this for the whole launch - /// and the stop that follows. - /// - /// ponytail: one process-wide lock. A free port per launch would also have - /// to move the wallet child's `--daemon-address`, which is the constant. - #[cfg(feature = "cuprate-daemon")] - pub(crate) fn unrestricted_port_lock() -> std::sync::MutexGuard<'static, ()> { - static LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); - LOCK.lock().unwrap_or_else(|e| e.into_inner()) - } - /// Holds every `--rpc-bind-port` a watched argv log publishes, for as long /// as this value lives. ///