wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
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.
This commit is contained in:
parent
e6b5024ad3
commit
35a19bc37c
12 changed files with 3785 additions and 53 deletions
|
|
@ -55,17 +55,23 @@ not something the app stores for you.
|
|||
## Chain source
|
||||
|
||||
The wallet needs a daemon for scan, verify, and spend. You pick one; OnionWire
|
||||
does not pick a public remote node for you. The three shapes are:
|
||||
does not pick a public remote node for you. The four shapes are:
|
||||
|
||||
```
|
||||
ChainSource::None receive-only; no child, no daemon
|
||||
ChainSource::Local { monerod_bin, datadir } the app spawns monerod on this box
|
||||
ChainSource::InProcessCuprate { datadir } the daemon is inside this app
|
||||
ChainSource::Remote { host, port } a daemon address you typed
|
||||
```
|
||||
|
||||
1. **Local `monerod`.** Chain traffic stays on the box. You accept disk, first
|
||||
sync, and (on Android) the daemon not always running.
|
||||
2. **A daemon address you supply** — becomes `--daemon-address` on the wallet
|
||||
2. **An in-process daemon** ([Cuprate](https://github.com/Cuprate/cuprate)
|
||||
running inside the OnionWire process). No `monerod` binary to install or
|
||||
spawn, chain on this device, and the wallet child dials the same loopback
|
||||
port. **Testnet only** in this build, and it needs the `cuprate-daemon`
|
||||
feature — see "The in-process chain daemon" below.
|
||||
3. **A daemon address you supply** — becomes `--daemon-address` on the wallet
|
||||
child. Loopback if you already run `monerod`. `.onion` if you want chain
|
||||
traffic over Tor — that needs a SOCKS proxy for the wallet child and is **not
|
||||
implemented here**: configuring a `.onion` host today fails with a clear error
|
||||
|
|
@ -75,15 +81,61 @@ ChainSource::Remote { host, port } a daemon address you typed
|
|||
The port is a convention, not a constant: restricted RPC on `18089` is common,
|
||||
but you supply it.
|
||||
|
||||
### The in-process chain daemon (`cuprate-daemon`)
|
||||
|
||||
Cuprate's chain daemon — P2P, consensus, RandomX — can run **inside the OnionWire
|
||||
process** instead of as a spawned `monerod`. The wallet layer does not change:
|
||||
`monero-wallet-rpc` is still a child, and it still dials the unrestricted loopback
|
||||
RPC, `127.0.0.1:18081`, the same address a spawned `monerod` gets.
|
||||
|
||||
```
|
||||
cargo build --release --features cuprate-daemon
|
||||
```
|
||||
|
||||
- **Off by default.** `cuprated` is pre-1.0 and is not published to crates.io, so
|
||||
it is a git dependency pinned to a revision. Without the feature the picker
|
||||
still shows the row — the chain-source type and its stored record do not fork
|
||||
on a cargo feature — but starting it fails with `this build has no in-process
|
||||
chain daemon — rebuild with --features cuprate-daemon`.
|
||||
- **+12.3 MB** on a stripped release binary, measured here: 26,942,168 bytes
|
||||
without the feature and 39,193,032 with it (`cargo build --release` with and
|
||||
without `--features cuprate-daemon`, then `strip` both). The +5.6 MB figure
|
||||
that circulated with the spike was an estimate and understates it. It also
|
||||
pulls a large build tree (RandomX, fjall, axum/hyper, rayon) — a cold build
|
||||
compiles ~586 crates in release — so a build from cold is noticeably longer
|
||||
than a plain TUI build.
|
||||
- **Testnet only.** Cuprate is pre-production and its `monerod` RPC parity is
|
||||
incomplete (`docs/cuprate-launch-spike.md` §Parity gaps). The config pins
|
||||
`network = "Testnet"`; pointing a mainnet wallet at it is not something this
|
||||
build claims to do. The picker row and the chain block both say so.
|
||||
- **No Tor in the chain path.** Cuprate's own `arti` feature is *not* enabled:
|
||||
its Tor stack is `arti-client` 0.44, which cannot unify with this crate's 0.46,
|
||||
and running two Tor stacks in one process is not a trade this app makes.
|
||||
OnionWire's Arti is the only Tor here, and it serves the messenger. That means
|
||||
the in-process daemon's P2P traffic is **clearnet**: your ISP can see that this
|
||||
device talks to Monero testnet peers, exactly as a spawned `monerod` would.
|
||||
- **Inbound connections are off** and the restricted RPC listener is disabled:
|
||||
this is a wallet's daemon, not a public node, and the restricted server only
|
||||
answers placeholder metrics (see below).
|
||||
- **It is not a child process.** There is no pid to watch or signal: the node is
|
||||
a value the app owns, and dropping it shuts the daemon down. `n` in the wallet
|
||||
screen stops it with the wallet child, and it does not outlive the app.
|
||||
- **The chain lives in `$ONIONWIRE_HOME/chain`** — the same per-identity
|
||||
directory a spawned `monerod` would use, so the two local sources are
|
||||
interchangeable on disk. Storage gate: the wallet screen reports free space
|
||||
there either way.
|
||||
|
||||
### The daemon you point at has to be its *unrestricted* RPC
|
||||
|
||||
Both the app-owned child and the chain probe behind the wallet screen dial the
|
||||
daemon's unrestricted listener: `--rpc-bind-port` for the `monerod` this app
|
||||
spawns (`127.0.0.1:18081`), and whatever port an in-process Cuprate binds for
|
||||
`[rpc.unrestricted]`. Never the restricted listener — it answers, so getting
|
||||
this wrong shows up as a *wrong number* rather than as an error. On Cuprate its
|
||||
restricted server reports a placeholder `database_size` (exactly 5 GiB), an
|
||||
empty `version`, and `free_space = u64::MAX` on both servers.
|
||||
spawns, and `[rpc.unrestricted]` for the in-process Cuprate — `127.0.0.1:18081`
|
||||
either way, which is why the chain source does not change the wallet child's
|
||||
argv. Never the restricted listener — it answers, so getting this wrong shows up
|
||||
as a *wrong number* rather than as an error. On Cuprate its restricted server
|
||||
reports a placeholder `database_size` (exactly 5 GiB), an empty `version`, and
|
||||
`free_space = u64::MAX` on both servers; the in-process daemon's restricted
|
||||
listener is disabled outright (`enable = false`).
|
||||
|
||||
What the wallet client reads from the daemon is chain height, and nothing else:
|
||||
`daemon_get_info` / `daemon_get_height` in `src/wallet.rs`. No peer count, no
|
||||
|
|
|
|||
Loading…
Reference in a new issue