wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature #95
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_ff1a80d7"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this is
Phase 1 of the Cuprate integration strategy (
docs/payment-integration-plan.md§7a): the chain daemon can run inside the OnionWire process instead of a spawnedmonerod.monero-wallet-rpcis unchanged. It is still a child, and it still dials the unrestricted loopback RPC on127.0.0.1:18081— the addressWalletChild::daemon_addressalready returned for a local source — so no wallet-layer code moves. What changes is who owns the chain.Base:
feat/wallet-create-import(this card's parent, as the wallet line is unmerged). Retarget tomainwhen that line lands.What changed
cuprated(git, rev4f8fcd1bf468f566fcd89c460d50de4adb6825bf) andtoml, both optional, behind acuprate-daemonfeature that is off by default. Cuprate's ownartifeature stays off: itsarti-client0.44 cannot unify with this crate's 0.46, and the in-process daemon is clearnet-only, so this keeps one Tor stack in the process.Cargo.lockgains the graph; no arti 0.44 appears in it (grep -cof the two versions: one, 0.46).CuprateNodebuilds the cuprated config as a TOML document (testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P off, no Tor P2P), launches it withNode::launch, and owns it. Dropping the value is the teardown;shutdown()is called first so the services can drain.ChainSource::InProcessCuprate(a datadir deep inside the variant).kind = "cuprate", and addschain_datadirso the storage gate covers both local sources. It takes the app's Tokio handle viawith_runtime:Node::launchis async andstart()runs on the TUI's blocking thread.wallet_child_start(runtime),default_in_process_chain_source().cuprate-daemon-gated end-to-end test.How it was verified
Size, measured rather than inherited:
cargo build --releasewith and without--features cuprate-daemon,stripboth, is 26,942,168 -> 39,193,032 bytes,so the in-process daemon costs +12.25 MB stripped. The +5.6 MB figure that
came with the spike is an estimate and understates it;
docs/WALLET.mdnowcarries the measured number and the command to re-derive it.
The
cuprate-daemontest is not a mock. It launches a real cuprated node in-process on a free loopback port and drives it through the same typed daemon client a remotemonerodgoes through:It asserts:
daemon_get_infoanswers and agrees with the node's ownblockchain.context().chain_height;target_heightis 0 on a peerless testnet node (which the UI must read as "unknown", not "caught up");daemon_get_heighton the URI endpoint agrees withget_info;get_blockat genesis returns a real blob; a height above the tip maps to the typedWalletError::DaemonHeightOutOfRange(Cuprate's bare HTTP 500); and after the value is dropped the RPC listener is gone.The lib also keeps its default-feature behaviour:
cargo test --libis 38 passed / 0 failed, includingin_process_source_without_the_feature_names_the_feature, which pins that a build without the feature refuses with the feature name and spawns nomonero-wallet-rpcagainst a daemon that never started.Deviations from the card, with reasons
cargo build --release --no-default-features --features cuprate-daemoncannot build, with or without this PR. The TLS backend here is a feature pair onarti-client(native-tlsdefault,rustlsalternative) and exactly one has to be selected. With neither, arti's runtime and onion-service types are configured out and this crate stops compiling —cargo check --no-default-features --features cuprate-daemonis RC 101 with four errors in its own Tor code:src/hs.rs:13unresolved importtor_rtcompat::PreferredRuntime,src/hs.rs:69noTorClient::create_bootstrapped, andsrc/node.rs:218/:1106Arc<RunningOnionService>vsRunningOnionServicemismatches. The honest commands are--features cuprate-daemonor--no-default-features --features rustls,cuprate-daemon; the literal one from the card is not achievable and never was.127.0.0.1:18081at startup" is not what the app does, and should not be. Nothing launches at startup: the chain source is the user's choice, receive-only is the default, and starting a chain daemon for every user would contradict the wallet screen. The daemon starts when the user starts the wallet child (n), which is the lifecycle the card's item 4 was reaching for. That lifecycle is wired: the child stops the node, and so does the quit path (which also stops the existing orphan-monero-wallet-rpcbehaviour — see item 5).CuprateDaemonwrapper insrc/wallet.rs(card item 3). The in-process node binds loopback RPC, and the typed client insrc/wallet.rsis already the Cuprate-parity client (this card's parent PR #94 landed exactly for these gaps). A second, in-process read path would duplicate the parity handling — the bare-500 height case and the URIget_height— and could bypass it. One code path was chosen deliberately.daemon_get_block()is still not wired into any scan path. The card says it "is now wired into the wallet scan path"; that is not true and was not true before this change — scanning ismonero-wallet-rpc's job.docs/WALLET.mdalready documents it as unwired, and this PR leaves that sentence alone because it is correct.Arc<Node>/Node::shutdown()shape (card item 2) is not cuprated's API.Node::launch(Config) -> Node,Dropcallsshutdown(), andshutdown()is&self. Implemented as an owned value in aMutex, withshutdown()before the drop.network = "Testnet"and the picker row, the saved note and the chain block all say so. Mainnet is not validated: Cuprate is pre-production and its monerod RPC parity is incomplete.p2p.tor_net.enabled = false, cuprate'sartifeature not enabled. The in-process daemon's P2P traffic is clearnet, anddocs/WALLET.mdsays so plainly.Scope deviations (files the card did not list)
src/tui.rsandsrc/node.rs: the picker row in item 5 cannot exist without them.tests/tui_frames.rs: it pinsChainChoice::ALL.len() == 3("three choices, never a public node"); the row is now four, and the comment was updated with it. One added mapping case.tests/tui_spec.rswas repaired. At the base commit it does not compile: the parent commit kept only its new imports and four new tests and dropped 1221 lines of body, leaving a danglingimpl Deliverer for Deadblock at file scope. It is restored from its pre-breakage version with the parent's imports and tests re-applied, and rustfmt-clean. Without this the acceptance command cannot pass at all.tests/tui_spec.rswas formatted as part of that restore.src/node.rs,src/tui.rs,src/wallet_child.rsandtests/tui_frames.rsare left at their inherited hunk counts — no repo-wide formatting, and no new hunks in files whose churn is inherited.Nothing here pushes
main, and no tagged release is implied.Phase 1 of the Cuprate integration strategy: the chain daemon can run inside the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081, which is the address `WalletChild::daemon_address` already returned — so no wallet-layer code moves. - Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a `cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the in-process daemon is clearnet-only, so this keeps one Tor stack in the process. `Cargo.lock` gains the graph; no arti 0.44 appears in it. - src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML (testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P off), launches it, and owns it. Dropping the value is the teardown; `shutdown()` is called before the drop so the services can drain. The type exists in every build: without the feature `launch` fails with the feature name instead of silently doing nothing, so the chain-source type, its stored record and the picker do not fork on a cargo feature. - src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`. - src/wallet_child.rs: starts/holds/stops the node, serializes the choice as `kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both local sources. It takes the app's Tokio handle (`with_runtime`): the launch is async and `start()` runs on the TUI's blocking thread. - src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`. - src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and a stop of the app-owned children on the quit path so they are not orphaned. - tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the node and drives get_info / get_height / get_block through the typed daemon client, including the above-the-tip 500 and the listener closing on drop. - docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB stripped overhead, and the two limits (testnet only, no Tor in the chain path). Also repaired tests/tui_spec.rs, which the parent commit left un-compilable (the Phase 2a commit had dropped all but the new imports and four new tests, 1221 lines of body); it is restored from the pre-breakage version, with the Phase 2a imports and tests re-applied.